(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func 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 | |
| 179 | func TestClickHouseFinalWithJoin(t *testing.T) { |
| 180 | sql := `SELECT * FROM orders FINAL JOIN users ON orders.user_id = users.id` |
nothing calls this directly
no test coverage detected