MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestClickHousePrewhereOnly

Function TestClickHousePrewhereOnly

pkg/sql/parser/clickhouse_test.go:72–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func 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
94func TestClickHousePrewhereNotParsedForOtherDialects(t *testing.T) {
95 // PREWHERE should not be parsed as a clause in non-ClickHouse dialects;

Callers

nothing calls this directly

Calls 3

ParseWithDialectFunction · 0.92
FatalfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected