Skip to content

Commit e9adc3a

Browse files
Backport ClickHouse#91040 to 25.8: Fix reading dynamic subcolumns from materialized columns in mutations
1 parent acc8e03 commit e9adc3a

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/Interpreters/TreeRewriter.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,11 +1024,6 @@ void TreeRewriterResult::collectSourceColumns(bool add_special)
10241024
source_columns.insert(source_columns.end(), columns_from_storage.begin(), columns_from_storage.end());
10251025

10261026
auto metadata_snapshot = storage->getInMemoryMetadataPtr();
1027-
source_columns_ordinary = metadata_snapshot->getColumns().getOrdinary();
1028-
}
1029-
else
1030-
{
1031-
source_columns_ordinary = source_columns;
10321027
}
10331028

10341029
source_columns_set = removeDuplicateColumns(source_columns);
@@ -1225,7 +1220,7 @@ bool TreeRewriterResult::collectUsedColumns(const ASTPtr & query, bool is_select
12251220
/// Check for subcolumns in unknown required columns.
12261221
if (!unknown_required_source_columns.empty() && (!storage || storage->supportsSubcolumns()))
12271222
{
1228-
for (const NameAndTypePair & pair : source_columns_ordinary)
1223+
for (const NameAndTypePair & pair : required_source_columns)
12291224
{
12301225
for (auto it = unknown_required_source_columns.begin(); it != unknown_required_source_columns.end();)
12311226
{

src/Interpreters/TreeRewriter.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ struct TreeRewriterResult
3434
/// Same as above but also record alias columns which are expanded. This is for RBAC access check.
3535
Names required_source_columns_before_expanding_alias_columns;
3636

37-
/// Set of columns that object columns are not extended. This is for distinguishing JSON and Tuple type.
38-
NamesAndTypesList source_columns_ordinary;
39-
4037
NameSet missed_subcolumns;
4138

4239
/// Set of alias columns that are expanded to their alias expressions. We still need the original columns to check access permission.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
drop table if exists test;
2+
create table test (s String, json JSON materialized s) engine=MergeTree order by tuple();
3+
insert into test select '{"a" : 42}';
4+
alter table test update s = '{}' where json.a = 42 settings mutations_sync=1;
5+
select * from test;
6+
drop table test;
7+

0 commit comments

Comments
 (0)