Skip to content

Commit

Permalink
planner: do not remove the first row func if it is a constant (#50286)
Browse files Browse the repository at this point in the history
close #38756
  • Loading branch information
ti-chi-bot authored Feb 26, 2024
1 parent 608c25e commit 4b94fe4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,12 @@ func RemoveUnnecessaryFirstRow(
// the firstrow in root task can not be removed.
break
}
// Skip if it's a constant.
// For SELECT DISTINCT SQRT(1) FROM t.
// We shouldn't remove the firstrow(SQRT(1)).
if _, ok := gbyExpr.(*expression.Constant); ok {
continue
}
if gbyExpr.Equal(sctx, aggFunc.Args[0]) {
canOptimize = true
firstRowFuncMap[aggFunc].Args[0] = finalGbyItems[j]
Expand Down

0 comments on commit 4b94fe4

Please sign in to comment.