Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,14 @@ public Expression visitAlias(Alias alias, DeepCopierContext context) {
@Override
public Expression visitSlotReference(SlotReference slotReference, DeepCopierContext context) {
Map<ExprId, ExprId> exprIdReplaceMap = context.exprIdReplaceMap;
ExprId newExprId;
if (exprIdReplaceMap.containsKey(slotReference.getExprId())) {
ExprId newExprId = exprIdReplaceMap.get(slotReference.getExprId());
return slotReference.withExprId(newExprId);
newExprId = exprIdReplaceMap.get(slotReference.getExprId());
} else {
SlotReference newOne = new SlotReference(slotReference.getName(), slotReference.getDataType(),
slotReference.nullable(), slotReference.getQualifier());
exprIdReplaceMap.put(slotReference.getExprId(), newOne.getExprId());
return newOne;
newExprId = StatementScopeIdGenerator.newExprId();
exprIdReplaceMap.put(slotReference.getExprId(), newExprId);
}
return slotReference.withExprId(newExprId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public R visitGroupingScalarFunction(GroupingScalarFunction groupingScalarFuncti
}

public R visitVirtualReference(VirtualSlotReference virtualSlotReference, C context) {
return visit(virtualSlotReference, context);
return visitSlotReference(virtualSlotReference, context);
}

public R visitVariableDesc(VariableDesc variableDesc, C context) {
Expand Down
3 changes: 3 additions & 0 deletions regression-test/data/nereids_p0/subquery/test_subquery.out
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ true 15 1992 3021 11011920 0.000 true 9999-12-12 2015-04-02T00:00 3.141592653 2
-- !sql_subquery_one_row_relation --
1

-- !sql_mark_join --
1

Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ suite("test_subquery") {

qt_sql_subquery_one_row_relation """select * from test_one_row_relation;"""

qt_sql_mark_join """with A as (select count(*) n1 from test_one_row_relation where exists (select 1 from test_one_row_relation t where t.user_id = test_one_row_relation.user_id) or 1 = 1) select * from A;"""

sql """drop table if exists test_one_row_relation;"""
}