[Fix](planner) fix select from inline table return only the first row (#24365)
This commit is contained in:
@ -231,11 +231,21 @@ public class InlineViewRef extends TableRef {
|
||||
String colName = getColLabels().get(i);
|
||||
SlotDescriptor slotDesc = analyzer.registerColumnRef(getAliasAsName(), colName);
|
||||
Expr colExpr = queryStmt.getResultExprs().get(i);
|
||||
slotDesc.setSourceExpr(colExpr);
|
||||
if (queryStmt instanceof SelectStmt && ((SelectStmt) queryStmt).getValueList() != null) {
|
||||
ValueList valueList = ((SelectStmt) queryStmt).getValueList();
|
||||
for (int j = 0; j < valueList.getRows().size(); ++j) {
|
||||
slotDesc.addSourceExpr(valueList.getRows().get(j).get(i));
|
||||
}
|
||||
} else {
|
||||
slotDesc.setSourceExpr(colExpr);
|
||||
}
|
||||
slotDesc.setIsNullable(slotDesc.getIsNullable() || colExpr.isNullable());
|
||||
SlotRef slotRef = new SlotRef(slotDesc);
|
||||
sMap.put(slotRef, colExpr);
|
||||
baseTblSmap.put(slotRef, queryStmt.getBaseTblResultExprs().get(i));
|
||||
// to solve select * from (values(1, 2, 3), (4, 5, 6)) a returns only one row.
|
||||
if (slotDesc.getSourceExprs().size() == 1) {
|
||||
sMap.put(slotRef, colExpr);
|
||||
baseTblSmap.put(slotRef, queryStmt.getBaseTblResultExprs().get(i));
|
||||
}
|
||||
if (createAuxPredicate(colExpr)) {
|
||||
analyzer.createAuxEquivPredicate(new SlotRef(slotDesc), colExpr.clone());
|
||||
}
|
||||
|
||||
@ -589,7 +589,7 @@ public class SelectStmt extends QueryStmt {
|
||||
} else {
|
||||
resultExprs.add(rewriteQueryExprByMvColumnExpr(expr, analyzer));
|
||||
}
|
||||
colLabels.add(expr.toColumnLabel());
|
||||
colLabels.add("col_" + colLabels.size());
|
||||
}
|
||||
}
|
||||
// analyze valueList if exists
|
||||
|
||||
@ -1647,7 +1647,13 @@ public class SingleNodePlanner {
|
||||
return unionNode;
|
||||
}
|
||||
unionNode.setTblRefIds(Lists.newArrayList(inlineViewRef.getId()));
|
||||
unionNode.addConstExprList(selectStmt.getBaseTblResultExprs());
|
||||
if (selectStmt.getValueList() != null) {
|
||||
for (List<Expr> row : selectStmt.getValueList().getRows()) {
|
||||
unionNode.addConstExprList(row);
|
||||
}
|
||||
} else {
|
||||
unionNode.addConstExprList(selectStmt.getBaseTblResultExprs());
|
||||
}
|
||||
unionNode.init(analyzer);
|
||||
//set outputSmap to substitute literal in outputExpr
|
||||
unionNode.setWithoutTupleIsNullOutputSmap(inlineViewRef.getSmap());
|
||||
|
||||
Reference in New Issue
Block a user