sql_validator.go 518 B

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