[fix](sort)the sort expr nullable info is wrong in some case (#12003)

This commit is contained in:
starocean999
2022-08-24 14:26:09 +08:00
committed by GitHub
parent 1304a17600
commit 81b6c8d9f9
3 changed files with 79 additions and 0 deletions

View File

@ -271,6 +271,11 @@ public class SortInfo {
*/
public ExprSubstitutionMap createMaterializedOrderExprs(
TupleDescriptor sortTupleDesc, Analyzer analyzer) {
// the sort node exprs may come from the child outer join node
// we need change the slots to nullable from all outer join nullable side temporarily
// then the sort node expr would have correct nullable info
// after create the output tuple we need revert the change by call analyzer.changeSlotsToNotNullable(slots)
List<SlotDescriptor> slots = analyzer.changeSlotToNullableOfOuterJoinedTuples();
ExprSubstitutionMap substOrderBy = new ExprSubstitutionMap();
for (Expr origOrderingExpr : orderingExprs) {
SlotDescriptor materializedDesc = analyzer.addSlotDescriptor(sortTupleDesc);
@ -280,6 +285,7 @@ public class SortInfo {
substOrderBy.put(origOrderingExpr, materializedRef);
materializedOrderingExprs.add(origOrderingExpr);
}
analyzer.changeSlotsToNotNullable(slots);
return substOrderBy;
}