diff --git a/dbms/src/Interpreters/MutationsInterpreter.cpp b/dbms/src/Interpreters/MutationsInterpreter.cpp index b1d5db40703..0c2e28c56df 100644 --- a/dbms/src/Interpreters/MutationsInterpreter.cpp +++ b/dbms/src/Interpreters/MutationsInterpreter.cpp @@ -286,12 +286,8 @@ void MutationsInterpreter::prepare(bool dry_run) { stages.emplace_back(context); for (const auto & column : affected_indices_columns) - { stages.back().column_to_updated.emplace( - column, - std::make_shared( - columns_desc.getPhysical(column).type->getName())); - } + column, std::make_shared(column)); } diff --git a/dbms/tests/queries/0_stateless/00935_mutate_index.reference b/dbms/tests/queries/0_stateless/00935_mutate_index.reference new file mode 100644 index 00000000000..6582a420c51 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00935_mutate_index.reference @@ -0,0 +1,4 @@ +10 +0 +0 +10 diff --git a/dbms/tests/queries/0_stateless/00935_mutate_index.sh b/dbms/tests/queries/0_stateless/00935_mutate_index.sh new file mode 100644 index 00000000000..5faa9c95bf9 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00935_mutate_index.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +CLICKHOUSE_CLIENT_OPT="--allow_experimental_data_skipping_indices=1" + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test.minmax_idx;" + + +$CLICKHOUSE_CLIENT -n --query=" +CREATE TABLE test.minmax_idx +( + u64 UInt64, + i64 Int64, + i32 Int32, + INDEX idx (i64, u64 * i64) TYPE minmax GRANULARITY 1 +) ENGINE = MergeTree() +ORDER BY u64 +SETTINGS index_granularity = 2;" + + +$CLICKHOUSE_CLIENT --query="INSERT INTO test.minmax_idx VALUES +(0, 1, 1), +(1, 1, 2), +(2, 1, 3), +(3, 1, 4), +(4, 1, 5), +(5, 1, 6), +(6, 1, 7), +(7, 1, 8), +(8, 1, 9), +(9, 1, 10)" + +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 1;" +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 5;" + +$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx UPDATE i64 = 5 WHERE i64 = 1;" + +sleep 0.1 + +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 1;" +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 5;" + +$CLICKHOUSE_CLIENT --query="DROP TABLE test.minmax_idx" \ No newline at end of file