parsePrewhereClause parses "PREWHERE " if present (ClickHouse-specific). PREWHERE is a ClickHouse optimisation that filters data blocks before reading all columns. It is semantically similar to WHERE but executed earlier in the query pipeline. Returns nil (no error) when PREWHERE is absent.
()
| 396 | // all columns. It is semantically similar to WHERE but executed earlier in the |
| 397 | // query pipeline. Returns nil (no error) when PREWHERE is absent. |
| 398 | func (p *Parser) parsePrewhereClause() (ast.Expression, error) { |
| 399 | if !p.isTokenMatch("PREWHERE") { |
| 400 | return nil, nil |
| 401 | } |
| 402 | p.advance() // Consume PREWHERE |
| 403 | |
| 404 | // Guard against a PREWHERE keyword with no following expression. |
| 405 | if p.isType(models.TokenTypeEOF) || p.isType(models.TokenTypeSemicolon) || |
| 406 | p.isType(models.TokenTypeWhere) || p.isType(models.TokenTypeGroup) || |
| 407 | p.isType(models.TokenTypeOrder) || p.isType(models.TokenTypeLimit) || |
| 408 | p.isType(models.TokenTypeHaving) || p.isType(models.TokenTypeUnion) || |
| 409 | p.isType(models.TokenTypeExcept) || p.isType(models.TokenTypeIntersect) || |
| 410 | p.isType(models.TokenTypeRParen) { |
| 411 | return nil, goerrors.ExpectedTokenError( |
| 412 | "expression after PREWHERE", |
| 413 | p.currentToken.Token.Type.String(), |
| 414 | p.currentLocation(), |
| 415 | "PREWHERE clause requires a boolean expression", |
| 416 | ) |
| 417 | } |
| 418 | |
| 419 | return p.parseExpression() |
| 420 | } |
| 421 | |
| 422 | // parseWhereClause parses "WHERE <expr>" if present. |
| 423 | // Returns nil (no error) when WHERE is absent. |
no test coverage detected