MCPcopy
hub / github.com/pingcap/tidb / findColFromNaturalUsingJoin

Function findColFromNaturalUsingJoin

pkg/planner/core/logical_plan_builder.go:1254–1265  ·  view source on GitHub ↗

findColFromNaturalUsingJoin is used to recursively find the column from the underlying natural-using-join. e.g. For SQL like `select t2.a from t1 join t2 using(a) where t2.a > 0`, the plan will be `join->selection->projection`. The schema of the `selection` will be `[t1.a]`, thus we need to recursiv

(p base.LogicalPlan, col *expression.Column)

Source from the content-addressed store, hash-verified

1252// will be `[t1.a]`, thus we need to recursively retrieve the `t2.a` from the
1253// underlying join.
1254func findColFromNaturalUsingJoin(p base.LogicalPlan, col *expression.Column) (name *types.FieldName) {
1255 switch x := p.(type) {
1256 case *logicalop.LogicalLimit, *logicalop.LogicalSelection, *logicalop.LogicalTopN, *logicalop.LogicalSort, *logicalop.LogicalMaxOneRow:
1257 return findColFromNaturalUsingJoin(p.Children()[0], col)
1258 case *logicalop.LogicalJoin:
1259 if x.FullSchema != nil {
1260 idx := x.FullSchema.ColumnIndex(col)
1261 return x.FullNames[idx]
1262 }
1263 }
1264 return nil
1265}
1266
1267type resolveGroupingTraverseAction struct {
1268 CurrentBlockExpand *logicalop.LogicalExpand

Callers 1

buildProjectionFieldMethod · 0.85

Calls 2

ColumnIndexMethod · 0.80
ChildrenMethod · 0.65

Tested by

no test coverage detected