Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/9305#discussion_r43421576
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
---
@@ -201,15 +200,24 @@ private[sql] object DataSourceStrategy extends
Strategy with Logging {
// Builds `AttributeReference`s for all partition columns so that we
can use them to project
// required partition columns. Note that if a partition column
appears in `requiredColumns`,
// we should use the `AttributeReference` in `requiredColumns`.
- val requiredColumnMap = requiredColumns.map(a => a.name -> a).toMap
- val partitionColumns = partitionColumnSchema.toAttributes.map { a =>
- requiredColumnMap.getOrElse(a.name, a)
+ val partitionColumns = {
+ val requiredColumnMap = requiredColumns.map(a => a.name -> a).toMap
+ partitionColumnSchema.toAttributes.map { a =>
+ requiredColumnMap.getOrElse(a.name, a)
+ }
}
val mapPartitionsFunc = (_: TaskContext, _: Int, iterator:
Iterator[InternalRow]) => {
- val projection = UnsafeProjection.create(requiredColumns,
dataColumns ++ partitionColumns)
+ // Note that we can't use an `UnsafeRowJoiner` to replace the
following `JoinedRow` and
+ // `UnsafeProjection`. Because the projection may also adjust
column order.
--- End diff --
I guess the problem is that the expected column lists can be `col1,
partCol1, col2, partCol2`. So, we need a projection anyway.
---
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]