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

Function TestWalk_NestedQueryDepthTracking

parser/walk_test.go:149–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestWalk_NestedQueryDepthTracking(t *testing.T) {
150 sql := `SELECT replica_name FROM system.ha_replicas UNION DISTINCT SELECT replica_name FROM system.ha_unique_replicas`
151 parser := NewParser(sql)
152 stmts, err := parser.ParseStmts()
153 require.NoError(t, err)
154 require.Equal(t, 1, len(stmts))
155
156 var tableNames []string
157
158 Walk(stmts[0], func(node Expr) bool {
159 // Track nesting depth
160 if tableID, ok := node.(*JoinTableExpr); ok {
161 tableName := Format(tableID.Table)
162 tableNames = append(tableNames, tableName+"@depth")
163 }
164 return true
165 })
166
167 require.Len(t, tableNames, 2, "Should find 2 table identifiers")
168}
169
170func TestWalk_SimpleNodeCounting(t *testing.T) {
171 sql := `SELECT a FROM table1`

Callers

nothing calls this directly

Calls 4

ParseStmtsMethod · 0.95
NewParserFunction · 0.85
WalkFunction · 0.85
FormatFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…