Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG] GROUPING func and ORDER BY are used at the same time to report …
…NullPointerException (#6266) fix #6265 The reason for the error is that the `Grouping Func Exprs` is substituted twice. In the first substitution, `VirtualSlotRef` is used to replace the original `SlotRef`, and in the second substitution, `VirtualSlotRef` is reported in the `getTable()` Times Null pointer. IN ``` } else if (((SlotRef) child).getDesc().getParent().getTable().getType() ``` For the first substitution, the List of executable exprs in select clause has been substituted. ``` groupingInfo = new GroupingInfo(analyzer, groupByClause.getGroupingType()); groupingInfo.substituteGroupingFn(resultExprs, analyzer); ``` In the second substitution, actually only need to substitute the unique expr in Ordering exprs. ``` createSortInfo(analyzer); if (sortInfo != null && CollectionUtils.isNotEmpty(sortInfo.getOrderingExprs())) { if (groupingInfo != null) { groupingInfo.substituteGroupingFn(sortInfo.getOrderingExprs(), analyzer); } } ``` change into: ``` createSortInfo(analyzer); if (sortInfo != null && CollectionUtils.isNotEmpty(sortInfo.getOrderingExprs())) { if (groupingInfo != null) { List<Expr> orderingExprNotInSelect = sortInfo.getOrderingExprs().stream() .filter(item -> !resultExprs.contains(item)).collect(Collectors.toList()); groupingInfo.substituteGroupingFn(orderingExprNotInSelect, analyzer); } } ```
- Loading branch information