Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHuaiyu committed Jul 3, 2020
1 parent cc60ac6 commit 5545dd6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,6 @@ type havingWindowAndOrderbyExprResolver struct {
inWindowFunc bool
inWindowSpec bool
inExpr bool
orderBy bool
err error
p LogicalPlan
selectFields []*ast.SelectField
Expand Down Expand Up @@ -1528,10 +1527,10 @@ func (a *havingWindowAndOrderbyExprResolver) Leave(n ast.Node) (node ast.Node, o
a.inWindowSpec = false
case *ast.ColumnNameExpr:
resolveFieldsFirst := true
if a.inAggFunc || a.inWindowFunc || a.inWindowSpec || (a.orderBy && a.inExpr) || a.curClause == fieldList {
if a.inAggFunc || a.inWindowFunc || a.inWindowSpec || (a.curClause == orderByClause && a.inExpr) || a.curClause == fieldList {
resolveFieldsFirst = false
}
if !a.inAggFunc && !a.orderBy {
if !a.inAggFunc && a.curClause != orderByClause {
for _, item := range a.gbyItems {
if col, ok := item.Expr.(*ast.ColumnNameExpr); ok &&
(colMatch(v.Name, col.Name) || colMatch(col.Name, v.Name)) {
Expand All @@ -1551,7 +1550,7 @@ func (a *havingWindowAndOrderbyExprResolver) Leave(n ast.Node) (node ast.Node, o
return node, false
}
if index == -1 {
if a.orderBy {
if a.curClause == orderByClause || a.curClause == havingClause {
index, a.err = a.resolveFromPlan(v, a.p)
} else {
index, a.err = resolveFromSelectFields(v, a.selectFields, true)
Expand Down Expand Up @@ -1624,7 +1623,6 @@ func (b *PlanBuilder) resolveHavingAndOrderBy(sel *ast.SelectStmt, p LogicalPlan
}
havingAggMapper := extractor.aggMapper
extractor.aggMapper = make(map[*ast.AggregateFuncExpr]int)
extractor.orderBy = true
extractor.inExpr = false
// Extract agg funcs from order by clause.
if sel.OrderBy != nil {
Expand Down

0 comments on commit 5545dd6

Please sign in to comment.