code: func (o *outerJoinEliminator) tryToEliminateOuterJoin(p *LogicalJoin, aggCols []*expression.Column, parentSchema *expression.Schema) (LogicalPlan, error) {
  	var innerChildIdx int
  	switch p.JoinType {
  	case LeftOuterJoin:
  		innerChildIdx = 1
  	case RightOuterJoin:
  		innerChildIdx = 0
  	default:
  		return p, nil
  	}
  
  	outerPlan := p.children[1^innerChildIdx]
  	innerPlan := p.children[innerChildIdx]
  	// outer join elimination with duplicate agnostic aggregate functions
  	matched, err := o.isAggColsAllFromOuterTable(outerPlan, aggCols)
  	if err != nil || matched {
  		return outerPlan, err
  	}
  	// outer join elimination without duplicate agnostic aggregate functions
  	matched, err = o.isParentColsAllFromOuterTable(outerPlan, parentSchema)
  	if err != nil || !matched {
  		return p, err
  	}
  	innerJoinKeys := o.extractInnerJoinKeys(p, innerChildIdx)
  	contain, err := o.isInnerJoinKeysContainUniqueKey(innerPlan, innerJoinKeys)
  	if err != nil || contain {
  		return outerPlan, err
  	}
  	contain, err = o.isInnerJoinKeysContainIndex(innerPlan, innerJoinKeys)
  	if err != nil || contain {
  		return outerPlan, err
  	}
  
  	return p, nil
  }
docs: // tryToEliminateOuterJoin will eliminate outer join plan base on the following rules
  // 1. outer join elimination: For example left outer join, if the parent only use the
  //    columns from left table and the join key of right table(the inner table) is a unique
  //    key of the right table. the left outer join can be eliminated.
  // 2. outer join elimination with duplicate agnostic aggregate functions: For example left outer join.
  //    If the parent only use the columns from left table with 'distinct' label. The left outer join can
  //    be eliminated.