Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22320#discussion_r214644583
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala 
---
    @@ -38,6 +38,20 @@ abstract class QueryPlan[PlanType <: 
QueryPlan[PlanType]] extends TreeNode[PlanT
        */
       def outputSet: AttributeSet = AttributeSet(output)
     
    +  /**
    +   * Returns output attributes with provided names.
    +   * The length of provided names should be the same of the length of 
[[output]].
    +   */
    +  def outputWithNames(names: Seq[String]): Seq[Attribute] = {
    +    // Save the output attributes to a variable to avoid duplicated 
function calls.
    +    val outputAttributes = output
    +    assert(outputAttributes.length == names.length,
    +      "The length of provided names doesn't match the length of output 
attributes.")
    +    outputAttributes.zipWithIndex.map { case (element, index) =>
    +      element.withName(names(index))
    +    }
    +  }
    +
    --- End diff --
    
    +1


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to