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 @@ -24,6 +24,7 @@
import org.apache.doris.analysis.Analyzer;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.FunctionCallExpr;
import org.apache.doris.analysis.SlotDescriptor;
import org.apache.doris.analysis.SlotId;
import org.apache.doris.analysis.TupleDescriptor;
import org.apache.doris.common.NotImplementedException;
Expand Down Expand Up @@ -363,6 +364,16 @@ public Set<SlotId> computeInputSlotIds(Analyzer analyzer) throws NotImplementedE
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);
}
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@
-- !select5 --
3

-- !select5 --
1
2
3

-- !select5 --
1
2
3

Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,50 @@ suite("test_inlineview_with_project") {
FROM test_01 ) TOTAL;
"""

qt_select5 """
SELECT
caseId
FROM
(
SELECT
caseId,
count(judgementDateId)
FROM
(
SELECT
abs(caseId) AS caseId,
id as judgementDateId
FROM
dr_user_test_t2
) AGG_RESULT
GROUP BY
caseId
) TOTAL
order by 1;
"""

qt_select5 """
SELECT
caseId
FROM
(
SELECT
caseId,
count(judgementDateId)
FROM
(
SELECT
caseId AS caseId,
abs(id) as judgementDateId
FROM
dr_user_test_t2
) AGG_RESULT
GROUP BY
caseId
) TOTAL
order by 1;
"""

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