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 @@ -373,16 +373,25 @@ public Set<SlotId> computeInputSlotIds(Analyzer analyzer) throws NotImplementedE
if (!tupleDesc.getMaterializedSlots().isEmpty()) {
result.add(tupleDesc.getMaterializedSlots().get(0).getId());
}
}
// if some input slot for aggregate slot which is not materialized, we need to remove it from the result
TupleDescriptor tupleDescriptor = aggInfo.getOutputTupleDesc();
ArrayList<SlotDescriptor> slots = tupleDescriptor.getSlots();
for (SlotDescriptor slot : slots) {
if (!slot.isMaterialized()) {
List<SlotId> unRequestIds = Lists.newArrayList();
Expr.getIds(slot.getSourceExprs(), null, unRequestIds);
unRequestIds.forEach(result::remove);
} else {
// if some input slot for aggregate slot which is not materialized, we need to remove it from the result
TupleDescriptor tupleDescriptor = aggInfo.getOutputTupleDesc();
ArrayList<SlotDescriptor> slots = tupleDescriptor.getSlots();
Set<SlotId> allUnRequestIds = Sets.newHashSet();
Set<SlotId> allRequestIds = Sets.newHashSet();
for (SlotDescriptor slot : slots) {
if (!slot.isMaterialized()) {
List<SlotId> unRequestIds = Lists.newArrayList();
Expr.getIds(slot.getSourceExprs(), null, unRequestIds);
allUnRequestIds.addAll(unRequestIds);
} else {
List<SlotId> requestIds = Lists.newArrayList();
Expr.getIds(slot.getSourceExprs(), null, requestIds);
allRequestIds.addAll(requestIds);
}
}
allRequestIds.forEach(allUnRequestIds::remove);
allUnRequestIds.forEach(result::remove);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
2
3

-- !select5 --
3

Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,47 @@ suite("test_inlineview_with_project") {
order by 1;
"""

qt_select5 """
select
count(*)
from
(
select
random(),
group_concat(cast(ga.column3 as varchar)) as column111
from
(
select
t1.id as id,
upper(t1.caseId) as column1,
t1.content as column3
from
(
select
id,
caseId,
content
from
dr_user_test_t2
limit
10
) t1
left join (
select
id,
caseId,
content
from
dr_user_test_t2
limit
10
) t2 on t1.id = t2.id
) as ga
group by
lower(ga.column3)
) as a;
"""

sql """DROP TABLE IF EXISTS `dr_user_test_t1`;"""
sql """DROP TABLE IF EXISTS `dr_user_test_t2`;"""
}