Compare commits

...

12 Commits

Author SHA1 Message Date
Konstantin Bogdanov
95378f8478
Merge d78bbae17b into 682eb4c92f 2024-11-27 18:57:24 +08:00
Nikita Fomichev
682eb4c92f
Merge pull request #72519 from ClickHouse/24.10_disable_shared_set_join
SettingsChangesHistory: disable allow_experimental_shared_set_join
2024-11-27 10:01:09 +00:00
Robert Schulze
9c893d4712
Merge pull request #72520 from ClickHouse/docs-cloud-atomic-default-engine
[Docs] Specify that Replicated is default engine for cloud
2024-11-27 08:53:36 +00:00
Justin de Guzman
b6725d33d1
[Docs] Specify that Replicated is default engine for cloud 2024-11-26 16:57:49 -08:00
Anton Popov
71b651d4a8
Merge pull request #72394 from CurtizJ/fix-functions-to-subcolumns
Fix mismatched types after applying `optimize_functions_to_subcolumns`
2024-11-27 00:21:26 +00:00
Nikita Fomichev
1166e93447 SettingsChangesHistory: disable allow_experimental_shared_set_join 2024-11-27 00:56:03 +01:00
Anton Popov
e8f548a9a1 Merge remote-tracking branch 'upstream/master' into HEAD 2024-11-26 17:24:34 +00:00
Anton Popov
0073a74881 fix mismatched types after optimize_function_to_subcolumns 2024-11-25 14:09:11 +00:00
Alexey Milovidov
d78bbae17b
Update 03233_insert_into_distributed_table_bug.sh 2024-11-09 16:30:54 +01:00
Konstantin Bogdanov
a0e2f6925e
temp-commit 2024-09-05 06:19:57 +02:00
Konstantin Bogdanov
d18bd05261
temp-commit 2024-09-05 04:24:47 +02:00
Konstantin Bogdanov
0692e36bd6
temp-commit 2024-09-05 03:47:26 +02:00
7 changed files with 86 additions and 9 deletions

View File

@ -6,7 +6,7 @@ sidebar_position: 10
# Atomic
It supports non-blocking [DROP TABLE](#drop-detach-table) and [RENAME TABLE](#rename-table) queries and atomic [EXCHANGE TABLES](#exchange-tables) queries. `Atomic` database engine is used by default.
It supports non-blocking [DROP TABLE](#drop-detach-table) and [RENAME TABLE](#rename-table) queries and atomic [EXCHANGE TABLES](#exchange-tables) queries. `Atomic` database engine is used by default. Note that on ClickHouse Cloud, the `Replicated` database engine is used by default.
## Creating a Database {#creating-a-database}

View File

@ -46,7 +46,7 @@ using NodeToSubcolumnTransformer = std::function<void(QueryTreeNodePtr &, Functi
void optimizeFunctionLength(QueryTreeNodePtr & node, FunctionNode &, ColumnContext & ctx)
{
/// Replace `length(argument)` with `argument.size0`
/// Replace `length(argument)` with `argument.size0`.
/// `argument` may be Array or Map.
NameAndTypePair column{ctx.column.name + ".size0", std::make_shared<DataTypeUInt64>()};
@ -56,8 +56,8 @@ void optimizeFunctionLength(QueryTreeNodePtr & node, FunctionNode &, ColumnConte
template <bool positive>
void optimizeFunctionEmpty(QueryTreeNodePtr &, FunctionNode & function_node, ColumnContext & ctx)
{
/// Replace `empty(argument)` with `equals(argument.size0, 0)` if positive
/// Replace `notEmpty(argument)` with `notEquals(argument.size0, 0)` if not positive
/// Replace `empty(argument)` with `equals(argument.size0, 0)` if positive.
/// Replace `notEmpty(argument)` with `notEquals(argument.size0, 0)` if not positive.
/// `argument` may be Array or Map.
NameAndTypePair column{ctx.column.name + ".size0", std::make_shared<DataTypeUInt64>()};
@ -136,19 +136,25 @@ std::map<std::pair<TypeIndex, String>, NodeToSubcolumnTransformer> node_transfor
},
{
{TypeIndex::Map, "mapKeys"},
[](QueryTreeNodePtr & node, FunctionNode & function_node, ColumnContext & ctx)
[](QueryTreeNodePtr & node, FunctionNode &, ColumnContext & ctx)
{
/// Replace `mapKeys(map_argument)` with `map_argument.keys`
NameAndTypePair column{ctx.column.name + ".keys", function_node.getResultType()};
const auto & data_type_map = assert_cast<const DataTypeMap &>(*ctx.column.type);
auto key_type = std::make_shared<DataTypeArray>(data_type_map.getKeyType());
NameAndTypePair column{ctx.column.name + ".keys", key_type};
node = std::make_shared<ColumnNode>(column, ctx.column_source);
},
},
{
{TypeIndex::Map, "mapValues"},
[](QueryTreeNodePtr & node, FunctionNode & function_node, ColumnContext & ctx)
[](QueryTreeNodePtr & node, FunctionNode &, ColumnContext & ctx)
{
/// Replace `mapValues(map_argument)` with `map_argument.values`
NameAndTypePair column{ctx.column.name + ".values", function_node.getResultType()};
const auto & data_type_map = assert_cast<const DataTypeMap &>(*ctx.column.type);
auto value_type = std::make_shared<DataTypeArray>(data_type_map.getValueType());
NameAndTypePair column{ctx.column.name + ".values", value_type};
node = std::make_shared<ColumnNode>(column, ctx.column_source);
},
},
@ -439,11 +445,16 @@ public:
if (!identifiers_to_optimize.contains(qualified_name))
return;
auto result_type = function_node->getResultType();
auto transformer_it = node_transformers.find({column.type->getTypeId(), function_node->getFunctionName()});
if (transformer_it != node_transformers.end())
{
ColumnContext ctx{std::move(column), first_argument_column_node->getColumnSource(), getContext()};
transformer_it->second(node, *function_node, ctx);
if (!result_type->equals(*node->getResultType()))
node = buildCastFunction(node, result_type, getContext());
}
}
};

View File

@ -117,7 +117,7 @@ static std::initializer_list<std::pair<ClickHouseVersion, SettingsChangesHistory
{"min_free_disk_ratio_to_perform_insert", 0.0, 0.0, "New setting."},
{"enable_named_columns_in_function_tuple", false, false, "Disabled pending usability improvements"},
{"cloud_mode_database_engine", 1, 1, "A setting for ClickHouse Cloud"},
{"allow_experimental_shared_set_join", 1, 1, "A setting for ClickHouse Cloud"},
{"allow_experimental_shared_set_join", 0, 0, "A setting for ClickHouse Cloud"},
{"read_through_distributed_cache", 0, 0, "A setting for ClickHouse Cloud"},
{"write_through_distributed_cache", 0, 0, "A setting for ClickHouse Cloud"},
{"distributed_cache_throw_on_error", 0, 0, "A setting for ClickHouse Cloud"},

View File

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Tags: distributed
# https://github.com/ClickHouse/ClickHouse/issues/65520
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
${CLICKHOUSE_CLIENT} -q "drop database if exists ${CLICKHOUSE_DATABASE}_db on cluster test_shard_localhost"
${CLICKHOUSE_CLIENT} -q "create database ${CLICKHOUSE_DATABASE}_db on cluster test_shard_localhost"
${CLICKHOUSE_CLIENT} -q "drop table if exists ${CLICKHOUSE_DATABASE}_db.segfault_table on cluster test_shard_localhost"
${CLICKHOUSE_CLIENT} -q "drop table if exists ${CLICKHOUSE_DATABASE}_db.__segfault_table on cluster test_shard_localhost"
${CLICKHOUSE_CLIENT} -q "
create table ${CLICKHOUSE_DATABASE}_db.__segfault_table on cluster test_shard_localhost (
c_mpcnr33 Int32 primary key,
c_v8s String,
c_l Int32,
c_jismi1 String,
c_p37t64z75 Bool not null,
c_uz Bool,
c_rp Int32 primary key,
c_d56dwp13jp Bool,
c_sf__xnd4 Float64 not null,
)"
${CLICKHOUSE_CLIENT} -q "create table ${CLICKHOUSE_DATABASE}_db.segfault_table on cluster test_shard_localhost as ${CLICKHOUSE_DATABASE}_db.__segfault_table ENGINE = Distributed(test_shard_localhost, ${CLICKHOUSE_DATABASE}_db, __segfault_table, c_mpcnr33)"
${CLICKHOUSE_CLIENT} -q "
create table ${CLICKHOUSE_DATABASE}_db.__t_nh1w on cluster test_shard_localhost (
c_sfdzg Int32,
c_xf Bool,
c_u3xs92nr4c String,
c_b_m Int32 primary key,
c_lgy Int32,
)"
${CLICKHOUSE_CLIENT} -q "create table ${CLICKHOUSE_DATABASE}_db.t_nh1w on cluster test_shard_localhost as ${CLICKHOUSE_DATABASE}_db.__t_nh1w ENGINE = Distributed(test_shard_localhost, ${CLICKHOUSE_DATABASE}_db, __t_nh1w, c_b_m)"
query="insert into ${CLICKHOUSE_DATABASE}_db.segfault_table (c_mpcnr33, c_v8s, c_l, c_jismi1, c_p37t64z75, c_uz, c_rp, c_d56dwp13jp, c_sf__xnd4) values (868701807, coalesce((select c_u3xs92nr4c from ${CLICKHOUSE_DATABASE}_db.t_nh1w order by c_u3xs92nr4c limit 1 offset 6), 'llwlzwb3'), 1824351772, coalesce(MACNumToString(lcm(-3, -6)), 'f'))"
# This was triggering a crash in the previous versions. The query can produce an error but should not lead to a crash.
curl -d@- -sS "${CLICKHOUSE_URL}" <<< "$query" >/dev/null 2>&1 ||:
${CLICKHOUSE_CLIENT} -q "drop table if exists ${CLICKHOUSE_DATABASE}_db.segfault_table on cluster test_shard_localhost"
${CLICKHOUSE_CLIENT} -q "drop table if exists ${CLICKHOUSE_DATABASE}_db.__segfault_table on cluster test_shard_localhost"

View File

@ -0,0 +1 @@
['foo'] ['bar']

View File

@ -0,0 +1,14 @@
DROP TABLE IF EXISTS t_map_lc;
CREATE TABLE t_map_lc
(
kv Map(LowCardinality(String), LowCardinality(String)),
k Array(LowCardinality(String)) ALIAS mapKeys(kv),
v Array(LowCardinality(String)) ALIAS mapValues(kv)
) ENGINE = Memory;
INSERT INTO t_map_lc VALUES (map('foo', 'bar'));
SELECT k, v FROM t_map_lc SETTINGS optimize_functions_to_subcolumns=1;
DROP TABLE t_map_lc;