MCPcopy Create free account
hub / github.com/AfterShip/clickhouse-sql-parser / TestParser_InvalidSyntax

Function TestParser_InvalidSyntax

parser/parser_test.go:173–196  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

171}
172
173func TestParser_InvalidSyntax(t *testing.T) {
174 invalidSQLs := []string{
175 "SELECT * FROM",
176 // WITH FILL error cases
177 "SELECT n FROM t ORDER BY n WITH", // WITH without FILL
178 "SELECT n FROM t ORDER BY n FILL", // FILL without WITH
179 "SELECT n FROM t ORDER BY n WITH FILL FROM", // FROM without value
180 "SELECT n FROM t ORDER BY n WITH FILL TO", // TO without value
181 "SELECT n FROM t ORDER BY n WITH FILL STEP", // STEP without value
182 "SELECT n FROM t ORDER BY n WITH FILL STALENESS", // STALENESS without value
183 "SELECT n FROM t ORDER BY n WITH FILL INTERPOLATE (x", // Missing closing paren
184 "SELECT n FROM t ORDER BY n WITH FILL INTERPOLATE x AS x + 1", // Missing parens around column list
185 "ALTER TABLE foo_mv MODIFY QUERY AS SELECT * FROM baz", // MODIFY QUERY followed by an invalid query
186 // Invalid ARRAY JOIN types (only ARRAY JOIN, LEFT ARRAY JOIN, and INNER ARRAY JOIN are valid)
187 "SELECT * FROM t RIGHT ARRAY JOIN arr AS a", // RIGHT ARRAY JOIN not supported
188 "SELECT * FROM t FULL ARRAY JOIN arr AS a", // FULL ARRAY JOIN not supported
189 "00e1d", // invalid number that leaves lastToken nil
190 }
191 for _, sql := range invalidSQLs {
192 parser := NewParser(sql)
193 _, err := parser.ParseStmts()
194 require.Error(t, err, "Expected error for SQL: %s", sql)
195 }
196}

Callers

nothing calls this directly

Calls 2

ParseStmtsMethod · 0.95
NewParserFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…