|
@@ -177,9 +177,9 @@ func buildOps(lp LogicalPlan, tp *topo.Topo, options *api.RuleOption, sources []
|
|
|
case *OrderPlan:
|
|
|
op = Transform(&operator.OrderOp{SortFields: t.SortFields}, fmt.Sprintf("%d_order", newIndex), options)
|
|
|
case *ProjectPlan:
|
|
|
- op = Transform(&operator.ProjectOp{ColNames: t.colNames, AliasNames: t.aliasNames, AliasFields: t.aliasFields, ExprFields: t.exprFields, ExceptNames: t.exceptNames, IsAggregate: t.isAggregate, AllWildcard: t.allWildcard, WildcardEmitters: t.wildcardEmitters, ExprNames: t.exprNames, SendMeta: t.sendMeta}, fmt.Sprintf("%d_project", newIndex), options)
|
|
|
+ op = Transform(&operator.ProjectOp{ColNames: t.colNames, AliasNames: t.aliasNames, AliasFields: t.aliasFields, ExprFields: t.exprFields, ExceptNames: t.exceptNames, IsAggregate: t.isAggregate, AllWildcard: t.allWildcard, WildcardEmitters: t.wildcardEmitters, ExprNames: t.exprNames, SendMeta: t.sendMeta, LimitCount: t.limitCount, EnableLimit: t.enableLimit}, fmt.Sprintf("%d_project", newIndex), options)
|
|
|
case *ProjectSetPlan:
|
|
|
- op = Transform(&operator.ProjectSetOperator{SrfMapping: t.SrfMapping}, fmt.Sprintf("%d_projectset", newIndex), options)
|
|
|
+ op = Transform(&operator.ProjectSetOperator{SrfMapping: t.SrfMapping, LimitCount: t.limitCount, EnableLimit: t.enableLimit}, fmt.Sprintf("%d_projectset", newIndex), options)
|
|
|
default:
|
|
|
err = fmt.Errorf("unknown logical plan %v", t)
|
|
|
}
|
|
@@ -463,20 +463,36 @@ func createLogicalPlan(stmt *ast.SelectStatement, opt *api.RuleOption, store kv.
|
|
|
children = []LogicalPlan{p}
|
|
|
}
|
|
|
|
|
|
+ srfMapping := extractSRFMapping(stmt)
|
|
|
if stmt.Fields != nil {
|
|
|
+ enableLimit := false
|
|
|
+ limitCount := 0
|
|
|
+ if stmt.Limit != nil && len(srfMapping) == 0 {
|
|
|
+ enableLimit = true
|
|
|
+ limitCount = stmt.Limit.(*ast.LimitExpr).LimitCount.Val
|
|
|
+ }
|
|
|
p = ProjectPlan{
|
|
|
fields: stmt.Fields,
|
|
|
isAggregate: xsql.WithAggFields(stmt),
|
|
|
sendMeta: opt.SendMetaToSink,
|
|
|
+ enableLimit: enableLimit,
|
|
|
+ limitCount: limitCount,
|
|
|
}.Init()
|
|
|
p.SetChildren(children)
|
|
|
children = []LogicalPlan{p}
|
|
|
}
|
|
|
|
|
|
- srfMapping := extractSRFMapping(stmt)
|
|
|
if len(srfMapping) > 0 {
|
|
|
+ enableLimit := false
|
|
|
+ limitCount := 0
|
|
|
+ if stmt.Limit != nil {
|
|
|
+ enableLimit = true
|
|
|
+ limitCount = stmt.Limit.(*ast.LimitExpr).LimitCount.Val
|
|
|
+ }
|
|
|
p = ProjectSetPlan{
|
|
|
- SrfMapping: srfMapping,
|
|
|
+ SrfMapping: srfMapping,
|
|
|
+ enableLimit: enableLimit,
|
|
|
+ limitCount: limitCount,
|
|
|
}.Init()
|
|
|
p.SetChildren(children)
|
|
|
}
|