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

Function TestClickHouseFinalWithAlias

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

Source from the content-addressed store, hash-verified

139}
140
141func TestClickHouseFinalWithAlias(t *testing.T) {
142 t.Run("ExplicitAlias", func(t *testing.T) {
143 sql := `SELECT * FROM orders AS o FINAL`
144 tree, err := parser.ParseWithDialect(sql, keywords.DialectClickHouse)
145 if err != nil {
146 t.Fatalf("unexpected error parsing FINAL with AS alias: %v", err)
147 }
148 if len(tree.Statements) == 0 {
149 t.Fatal("expected at least one statement")
150 }
151 sel, ok := tree.Statements[0].(*ast.SelectStatement)
152 if !ok {
153 t.Fatalf("expected SelectStatement, got %T", tree.Statements[0])
154 }
155 if len(sel.From) == 0 || !sel.From[0].Final {
156 t.Error("expected FINAL=true on first TableReference")
157 }
158 })
159
160 t.Run("ImplicitAlias", func(t *testing.T) {
161 sql := `SELECT * FROM orders o FINAL`
162 tree, err := parser.ParseWithDialect(sql, keywords.DialectClickHouse)
163 if err != nil {
164 t.Fatalf("unexpected error parsing FINAL with implicit alias: %v", err)
165 }
166 if len(tree.Statements) == 0 {
167 t.Fatal("expected at least one statement")
168 }
169 sel, ok := tree.Statements[0].(*ast.SelectStatement)
170 if !ok {
171 t.Fatalf("expected SelectStatement, got %T", tree.Statements[0])
172 }
173 if len(sel.From) == 0 || !sel.From[0].Final {
174 t.Error("expected FINAL=true on first TableReference")
175 }
176 })
177}
178
179func TestClickHouseFinalWithJoin(t *testing.T) {
180 sql := `SELECT * FROM orders FINAL JOIN users ON orders.user_id = users.id`

Callers

nothing calls this directly

Calls 4

ParseWithDialectFunction · 0.92
RunMethod · 0.80
FatalfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected