Skip to content

Commit 52b2bc7

Browse files
committed
Fix proper detection of virtual base class
1 parent 0b46d57 commit 52b2bc7

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/Interpreters/OptimizeIfWithConstantConditionVisitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void OptimizeIfWithConstantConditionVisitorData::visit(ASTFunction & function_no
9898
if (tryExtractConstValueFromCondition(condition_expr, condition))
9999
{
100100
ASTPtr replace_ast = condition ? then_expr : else_expr;
101-
bool replacement_supports_alias = replace_ast->as<ASTWithAlias>() != nullptr;
101+
bool replacement_supports_alias = dynamic_cast<ASTWithAlias *>(replace_ast.get());
102102
String if_alias = ast->tryGetAlias();
103103
/// We cannot set the resulting alias if the replace ast does not support it (e.g. ASTAsterisk), so it's better to do nothing
104104
if (!if_alias.empty() && !replacement_supports_alias)

src/Interpreters/TreeRewriter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,13 @@ void renameDuplicatedColumns(const ASTSelectQuery * select_query)
365365

366366
for (auto & expr : elements)
367367
{
368-
/// We can't rename with aliases if it doesn't support alias (e.g. asterisk)
369-
if (!expr->as<ASTWithAlias>())
370-
continue;
371-
372368
auto name = expr->getAliasOrColumnName();
373-
374369
if (!assigned_column_names.insert(name).second)
375370
{
371+
/// We can't rename with aliases if it doesn't support alias (e.g. asterisk)
372+
if (!dynamic_cast<ASTWithAlias *>(expr.get()))
373+
continue;
374+
376375
size_t i = 1;
377376
while (all_column_names.end() != all_column_names.find(name + "_" + toString(i)))
378377
++i;

tests/queries/0_stateless/03444_explain_asterisk.reference

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ CROSS JOIN
4747
b,
4848
isZeroOrNull(10),
4949
10,
50+
10 AS `10_1`,
51+
10 AS `10_2`,
5052
assumeNotNull(materialize(10)),
5153
10 IS NOT NULL,
5254
a AS x

0 commit comments

Comments
 (0)