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 @@ -662,8 +662,13 @@ public void createSmaps(Analyzer analyzer) {
exprs.addAll(aggregateExprs_);
for (int i = 0; i < exprs.size(); ++i) {
Expr expr = exprs.get(i);
outputTupleSmap_.put(expr.clone(),
new SlotRef(outputTupleDesc_.getSlots().get(i)));
if (expr.isImplicitCast()) {
outputTupleSmap_.put(expr.getChild(0).clone(),
new SlotRef(outputTupleDesc_.getSlots().get(i)));
} else {
outputTupleSmap_.put(expr.clone(),
new SlotRef(outputTupleDesc_.getSlots().get(i)));
}
if (!requiresIntermediateTuple()) continue;

intermediateTupleSmap_.put(expr.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public Expr clone() {
}

public SlotDescriptor getDesc() {
Preconditions.checkState(isAnalyzed);
Preconditions.checkNotNull(desc);
return desc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,21 @@ public void testConvertCaseWhenToConstant() throws Exception {
// 4.2.1 test null in when expr
String sql421 = "select case 'a' when null then 'a' else 'other' end as col421";
Assert.assertTrue(StringUtils.containsIgnoreCase(UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql421), "constant exprs: \n 'other'"));

// 5.1 test same type in then expr and else expr
String sql51 = "select case when 132 then k7 else 'all' end as col51 from test.baseall group by col51";
Assert.assertTrue(StringUtils.containsIgnoreCase(UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql51),
"OUTPUT EXPRS: CASE WHEN 132 THEN `k7` ELSE 'all' END"));

// 5.2 test same type in then expr and else expr
String sql52 = "select case when 2 < 1 then 'all' else k7 end as col52 from test.baseall group by col52";
Assert.assertTrue(StringUtils.containsIgnoreCase(UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql52),
"OUTPUT EXPRS: `k7`"));

// 5.3 test different in then expr and else expr, and return CastExpr<SlotRef>
String sql53 = "select case when 2 < 1 then 'all' else k1 end as col53 from test.baseall group by col53";
Assert.assertTrue(StringUtils.containsIgnoreCase(UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql53),
"OUTPUT EXPRS:<slot 0> `k1`"));
}

@Test
Expand Down