(t *testing.T)
| 147 | } |
| 148 | |
| 149 | func 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 | |
| 170 | func TestWalk_SimpleNodeCounting(t *testing.T) { |
| 171 | sql := `SELECT a FROM table1` |
nothing calls this directly
no test coverage detected
searching dependent graphs…