Github user nongli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11248#discussion_r53710181
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegen.scala 
---
    @@ -276,19 +286,32 @@ case class WholeStageCodegen(plan: CodegenSupport, 
children: Seq[SparkPlan])
         // println(s"${CodeFormatter.format(cleanedSource)}")
         CodeGenerator.compile(cleanedSource)
     
    -    plan.upstream().mapPartitions { iter =>
    -
    -      val clazz = CodeGenerator.compile(source)
    -      val buffer = 
clazz.generate(references).asInstanceOf[BufferedRowIterator]
    -      buffer.setInput(iter)
    -      new Iterator[InternalRow] {
    -        override def hasNext: Boolean = buffer.hasNext
    -        override def next: InternalRow = buffer.next()
    +    val rdds = plan.upstreams()
    +    if (rdds.length == 1) {
    +      rdds.head.mapPartitions { iter =>
    +        val clazz = CodeGenerator.compile(cleanedSource)
    +        val buffer = 
clazz.generate(references).asInstanceOf[BufferedRowIterator]
    +        buffer.init(Array(iter))
    +        new Iterator[InternalRow] {
    +          override def hasNext: Boolean = buffer.hasNext
    +          override def next: InternalRow = buffer.next()
    +        }
    +      }
    +    } else {
    +      // Right now, we support up to two upstreams.
    --- End diff --
    
    Add an assert


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to