sqlValidator.go 569 B

123456789101112131415161718192021
  1. package xsql
  2. import (
  3. "fmt"
  4. "github.com/emqx/kuiper/pkg/ast"
  5. )
  6. // Validate validate select statement without context.
  7. // This is the pre-validation. In planner, there will be a more comprehensive validation after binding
  8. func Validate(stmt *ast.SelectStatement) error {
  9. if ast.HasAggFuncs(stmt.Condition) {
  10. return fmt.Errorf("Not allowed to call aggregate functions in WHERE clause.")
  11. }
  12. for _, d := range stmt.Dimensions {
  13. if ast.HasAggFuncs(d.Expr) {
  14. return fmt.Errorf("Not allowed to call aggregate functions in GROUP BY clause.")
  15. }
  16. }
  17. return nil
  18. }