mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Merge pull request #41281 from ClickHouse/fix-key-condition-with-actions-dag-literal-name
Fix wrong literal name in KeyCondition using ActionsDAG.
This commit is contained in:
commit
16f78eb804
@ -116,10 +116,20 @@ static void appendColumnNameWithoutAlias(const ActionsDAG::Node & node, WriteBuf
|
||||
{
|
||||
switch (node.type)
|
||||
{
|
||||
case (ActionsDAG::ActionType::INPUT): [[fallthrough]];
|
||||
case (ActionsDAG::ActionType::COLUMN):
|
||||
case (ActionsDAG::ActionType::INPUT):
|
||||
writeString(node.result_name, out);
|
||||
break;
|
||||
case (ActionsDAG::ActionType::COLUMN):
|
||||
{
|
||||
/// If it was created from ASTLiteral, then result_name can be an alias.
|
||||
/// We need to convert value back to string here.
|
||||
if (const auto * column_const = typeid_cast<const ColumnConst *>(node.column.get()))
|
||||
writeString(applyVisitor(FieldVisitorToString(), column_const->getField()), out);
|
||||
/// It may be possible that column is ColumnSet
|
||||
else
|
||||
writeString(node.result_name, out);
|
||||
break;
|
||||
}
|
||||
case (ActionsDAG::ActionType::ALIAS):
|
||||
appendColumnNameWithoutAlias(*node.children.front(), out, legacy);
|
||||
break;
|
||||
|
@ -0,0 +1 @@
|
||||
2000
|
@ -0,0 +1,10 @@
|
||||
create table tba (event_id Int64, event_dt Int64) Engine =MergeTree order by event_id ;
|
||||
insert into tba select number%500, 20220822 from numbers(1e6);
|
||||
|
||||
select count() from (
|
||||
SELECT event_dt FROM (
|
||||
select event_dt, 403 AS event_id from (
|
||||
select event_dt from tba as tba
|
||||
where event_id = 9 and ((tba.event_dt >= 20220822 and tba.event_dt <= 20220822))
|
||||
)
|
||||
) tba WHERE tba.event_dt >= 20220822 and tba.event_dt <= 20220822 and event_id = 403 );
|
Loading…
Reference in New Issue
Block a user