(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestClickHousePrewhereOnly(t *testing.T) { |
| 73 | // PREWHERE without WHERE — also valid in ClickHouse |
| 74 | sql := `SELECT id FROM logs PREWHERE level = 'error'` |
| 75 | tree, err := parser.ParseWithDialect(sql, keywords.DialectClickHouse) |
| 76 | if err != nil { |
| 77 | t.Fatalf("unexpected error: %v", err) |
| 78 | } |
| 79 | if len(tree.Statements) == 0 { |
| 80 | t.Fatal("expected at least one statement") |
| 81 | } |
| 82 | sel, ok := tree.Statements[0].(*ast.SelectStatement) |
| 83 | if !ok { |
| 84 | t.Fatalf("expected SelectStatement, got %T", tree.Statements[0]) |
| 85 | } |
| 86 | if sel.PrewhereClause == nil { |
| 87 | t.Error("expected PrewhereClause to be set") |
| 88 | } |
| 89 | if sel.Where != nil { |
| 90 | t.Error("expected WhereClause to be nil when absent") |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | func TestClickHousePrewhereNotParsedForOtherDialects(t *testing.T) { |
| 95 | // PREWHERE should not be parsed as a clause in non-ClickHouse dialects; |
nothing calls this directly
no test coverage detected