From 37b221eac28946fe9cb523ba2c0f517e844e0e92 Mon Sep 17 00:00:00 2001 From: murphy-4o Date: Wed, 18 Mar 2026 12:54:36 +0000 Subject: [PATCH] Merge pull request #99838 from Desel72/fix-iceberg-modify-column-comment-crash Reject unsupported MODIFY COLUMN on Iceberg tables to prevent crash --- .../DataLakes/Iceberg/IcebergMetadata.cpp | 10 +++++++ ...r_modify_column_comment_segfault.reference | 1 + ...rg_alter_modify_column_comment_segfault.sh | 28 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.reference create mode 100755 tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.sh diff --git a/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp b/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp index 58f2926cc07e..ebe5c291c3c2 100644 --- a/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp +++ b/src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp @@ -545,6 +545,16 @@ void IcebergMetadata::checkAlterIsPossible(const AlterCommands & commands) if (command.type != AlterCommand::Type::ADD_COLUMN && command.type != AlterCommand::Type::DROP_COLUMN && command.type != AlterCommand::Type::MODIFY_COLUMN) throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Alter of type '{}' is not supported by Iceberg storage", command.type); + + if (command.type == AlterCommand::Type::MODIFY_COLUMN && command.to_remove != AlterCommand::RemoveProperty::NO_PROPERTY) + throw Exception( + ErrorCodes::NOT_IMPLEMENTED, + "Removing column property '{}' from column '{}' is not supported by Iceberg storage", command.to_remove, command.column_name); + + if (command.type == AlterCommand::Type::MODIFY_COLUMN && !command.data_type) + throw Exception( + ErrorCodes::NOT_IMPLEMENTED, + "Modifying column '{}' without changing its type is not supported by Iceberg storage", command.column_name); } } diff --git a/tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.reference b/tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.reference new file mode 100644 index 000000000000..23fb9dac9555 --- /dev/null +++ b/tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.reference @@ -0,0 +1 @@ +NOT_IMPLEMENTED diff --git a/tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.sh b/tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.sh new file mode 100755 index 000000000000..69b07a2db708 --- /dev/null +++ b/tests/queries/0_stateless/04042_iceberg_alter_modify_column_comment_segfault.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +# Regression test for https://github.com/ClickHouse/ClickHouse/issues/99523 +# ALTER TABLE ... MODIFY COLUMN ... COMMENT on an Iceberg table +# should return an error instead of causing a segfault. + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +TABLE="t_${CLICKHOUSE_DATABASE}_${RANDOM}" +TABLE_PATH="${USER_FILES_PATH}/${TABLE}/" + +${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS ${TABLE}" +${CLICKHOUSE_CLIENT} --query " + CREATE TABLE ${TABLE} (c0 Int) + ENGINE = IcebergLocal('${TABLE_PATH}') +" +# To have at least one real snapshot. Otherwise alter can be noop. +${CLICKHOUSE_CLIENT} --allow_insert_into_iceberg=1 --query "INSERT INTO ${TABLE} VALUES (1)" + +${CLICKHOUSE_CLIENT} --query " + ALTER TABLE ${TABLE} MODIFY COLUMN c0 COMMENT 'hello' +" 2>&1 | grep -o -m1 "NOT_IMPLEMENTED" + +${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS ${TABLE}" +rm -rf "${TABLE_PATH}"