code: func DoOptimize(flag uint64, logic LogicalPlan) (PhysicalPlan, error) {
  	logic, err := logicalOptimize(flag, logic)
  	if err != nil {
  		return nil, err
  	}
  	if !AllowCartesianProduct.Load() && existsCartesianProduct(logic) {
  		return nil, errors.Trace(ErrCartesianProductUnsupported)
  	}
  	physical, err := physicalOptimize(logic)
  	if err != nil {
  		return nil, err
  	}
  	finalPlan := postOptimize(physical)
  	return finalPlan, nil
  }
docs: // DoOptimize optimizes a logical plan to a physical plan.