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

    https://github.com/apache/spark/pull/6726#discussion_r32074429
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/sources/commands.scala ---
    @@ -218,24 +218,20 @@ private[sql] case class InsertIntoHadoopFsRelation(
             val partitionProj = newProjection(codegenEnabled, partitionOutput, 
output)
             val dataProj = newProjection(codegenEnabled, dataOutput, output)
     
    -        if (needsConversion) {
    -          val converter = 
CatalystTypeConverters.createToScalaConverter(dataSchema)
    -          while (iterator.hasNext) {
    -            val row = iterator.next()
    -            val partitionPart = partitionProj(row)
    -            val dataPart = dataProj(row)
    -            val convertedDataPart = converter(dataPart).asInstanceOf[Row]
    -            
writerContainer.outputWriterForRow(partitionPart).write(convertedDataPart)
    -          }
    +        val partitionSchema = StructType.fromAttributes(partitionOutput)
    +        val partConverter = 
CatalystTypeConverters.createToScalaConverter(partitionSchema)
    --- End diff --
    
    Hmm, looks like I got confused here.  I thought that we were converting to 
Catalyst, but I guess we're actually converting from Catalyst to Scala.  In 
that case, I guess it makes sense that we need to convert the result of the 
projection in the `!needsConversion` branch, since even if we already have a 
Scala row its projection might be Catalyst.  It looks like the old code might 
have actually contained a mistake here, since I think we'd also need to convert 
the projection in the `needsConversion` branch, too.  Therefore, this looks 
okay to me.


---
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