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

Function TestClickHousePrewhere

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

Source from the content-addressed store, hash-verified

24)
25
26func TestClickHousePrewhere(t *testing.T) {
27 sql := `SELECT id, name FROM events PREWHERE type = 'click' WHERE date >= '2024-01-01'`
28 tree, err := parser.ParseWithDialect(sql, keywords.DialectClickHouse)
29 if err != nil {
30 t.Fatalf("unexpected error: %v", err)
31 }
32 if len(tree.Statements) == 0 {
33 t.Fatal("expected at least one statement")
34 }
35 sel, ok := tree.Statements[0].(*ast.SelectStatement)
36 if !ok {
37 t.Fatalf("expected SelectStatement, got %T", tree.Statements[0])
38 }
39 if sel.PrewhereClause == nil {
40 t.Error("expected PrewhereClause to be set")
41 }
42 if sel.Where == nil {
43 t.Error("expected WhereClause to be set")
44 }
45}
46
47func TestClickHouseFinal(t *testing.T) {
48 sql := `SELECT * FROM orders FINAL`

Callers

nothing calls this directly

Calls 3

ParseWithDialectFunction · 0.92
FatalfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected