windowPlan.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package planner
  2. import "github.com/emqx/kuiper/xsql"
  3. type WindowPlan struct {
  4. baseLogicalPlan
  5. condition xsql.Expr
  6. wtype xsql.WindowType
  7. length int
  8. interval int //If interval is not set, it is equals to Length
  9. limit int //If limit is not positive, there will be no limit
  10. isEventTime bool
  11. }
  12. func (p WindowPlan) Init() *WindowPlan {
  13. p.baseLogicalPlan.self = &p
  14. return &p
  15. }
  16. func (p *WindowPlan) PushDownPredicate(condition xsql.Expr) (xsql.Expr, LogicalPlan) {
  17. if p.wtype == xsql.COUNT_WINDOW {
  18. return condition, p
  19. } else if p.isEventTime {
  20. // TODO event time filter, need event window op support
  21. //p.condition = combine(condition, p.condition)
  22. //// push nil condition won't return any
  23. //p.baseLogicalPlan.PushDownPredicate(nil)
  24. // return nil, p
  25. return condition, p
  26. } else {
  27. //Presume window condition are only one table related.
  28. // TODO window condition validation
  29. a := combine(condition, p.condition)
  30. p.condition, _ = p.baseLogicalPlan.PushDownPredicate(a)
  31. return nil, p
  32. }
  33. }
  34. func (p *WindowPlan) PruneColumns(fields []xsql.Expr) error {
  35. f := getFields(p.condition)
  36. return p.baseLogicalPlan.PruneColumns(append(fields, f...))
  37. }