Merge pull request #57461 from ClickHouse/fix-ephemeral-matview

Fix: don't exclude ephemeral column when building pushing to view chain
This commit is contained in:
Yakov Olkhovskiy 2023-12-06 16:46:54 -05:00 committed by GitHub
commit ac7210b9b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 1 deletions

View File

@ -349,7 +349,7 @@ Chain buildPushingToViewsChain(
for (const auto & column : header)
{
/// But skip columns which storage doesn't have.
if (inner_table_columns.hasPhysical(column.name))
if (inner_table_columns.hasNotAlias(column.name))
insert_columns.emplace_back(column.name);
}

View File

@ -668,6 +668,12 @@ bool ColumnsDescription::hasPhysical(const String & column_name) const
it->default_desc.kind != ColumnDefaultKind::Alias && it->default_desc.kind != ColumnDefaultKind::Ephemeral;
}
bool ColumnsDescription::hasNotAlias(const String & column_name) const
{
auto it = columns.get<1>().find(column_name);
return it != columns.get<1>().end() && it->default_desc.kind != ColumnDefaultKind::Alias;
}
bool ColumnsDescription::hasAlias(const String & column_name) const
{
auto it = columns.get<1>().find(column_name);

View File

@ -182,6 +182,7 @@ public:
Names getNamesOfPhysical() const;
bool hasPhysical(const String & column_name) const;
bool hasNotAlias(const String & column_name) const;
bool hasAlias(const String & column_name) const;
bool hasColumnOrSubcolumn(GetColumnsOptions::Kind kind, const String & column_name) const;
bool hasColumnOrNested(GetColumnsOptions::Kind kind, const String & column_name) const;

View File

@ -0,0 +1,2 @@
3 3
42 42

View File

@ -0,0 +1,30 @@
CREATE TABLE raw
(
name String,
num String
) ENGINE = MergeTree
ORDER BY (name);
CREATE TABLE parsed_eph
(
name String,
num_ephemeral UInt32 EPHEMERAL,
num UInt32 MATERIALIZED num_ephemeral,
) ENGINE = MergeTree
ORDER BY (name);
CREATE MATERIALIZED VIEW parse_mv_eph
TO parsed_eph
AS
SELECT
name,
toUInt32(num) as num_ephemeral
FROM raw;
INSERT INTO raw VALUES ('3', '3'), ('42', '42');
SELECT name, num FROM parsed_eph;
DROP VIEW parse_mv_eph;
DROP TABLE parsed_eph;
DROP TABLE raw;