code: func (b *PlanBuilder) resolveWindowFunction(sel *ast.SelectStmt, p LogicalPlan) (
  	map[*ast.AggregateFuncExpr]int, error) {
  	extractor := &havingWindowAndOrderbyExprResolver{
  		p:            p,
  		selectFields: sel.Fields.Fields,
  		aggMapper:    make(map[*ast.AggregateFuncExpr]int),
  		colMapper:    b.colMapper,
  		outerSchemas: b.outerSchemas,
  	}
  	extractor.curClause = windowClause
  	for _, field := range sel.Fields.Fields {
  		if !ast.HasWindowFlag(field.Expr) {
  			continue
  		}
  		n, ok := field.Expr.Accept(extractor)
  		if !ok {
  			return nil, extractor.err
  		}
  		field.Expr = n.(ast.ExprNode)
  	}
  	for _, spec := range sel.WindowSpecs {
  		_, ok := spec.Accept(extractor)
  		if !ok {
  			return nil, extractor.err
  		}
  	}
  	sel.Fields.Fields = extractor.selectFields
  	return extractor.aggMapper, nil
  }
docs: // resolveWindowFunction will process window functions and resolve the columns that don't exist in select fields.