MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestDorisSQLParser

Function TestDorisSQLParser

backend/plugin/parser/doris/doris_test.go:9–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestDorisSQLParser(t *testing.T) {
10 tests := []struct {
11 statement string
12 errorMessage string
13 }{
14 {
15 statement: "SELECT * FROM person LATERAL VIEW EXPLODE(ARRAY(30, 60)) tableName AS c_age;",
16 },
17 {
18 statement: "SELECT * FROM schema1.t1 JOIN schema2.t2 ON t1.c1 = t2.c1",
19 },
20 {
21 // Truncated SELECT — must be reported as a syntax error.
22 statement: "SELECT a > (select max(a) from t1) FROM",
23 errorMessage: "syntax error at end of input",
24 },
25 }
26
27 for _, test := range tests {
28 res, err := parseDorisSQL(test.statement)
29 if test.errorMessage == "" {
30 require.NoError(t, err)
31 require.NotEmpty(t, res)
32 require.NotNil(t, res[0].Node())
33 } else {
34 require.Error(t, err)
35 require.Contains(t, err.Error(), test.errorMessage)
36 }
37 }
38}

Callers

nothing calls this directly

Calls 3

parseDorisSQLFunction · 0.85
NodeMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected