EnricoMi commented on code in PR #39475:
URL: https://github.com/apache/spark/pull/39475#discussion_r1065398291
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/V1Writes.scala:
##########
@@ -91,32 +92,31 @@ object V1Writes extends Rule[LogicalPlan] with
SQLConfHelper {
}
private def prepareQuery(write: V1WriteCommand, query: LogicalPlan):
LogicalPlan = {
- val hasEmpty2Null = query.exists(p => hasEmptyToNull(p.expressions))
- val empty2NullPlan = if (hasEmpty2Null) {
- query
- } else {
- val projectList = convertEmptyToNull(query.output,
write.partitionColumns)
- if (projectList.isEmpty) query else Project(projectList, query)
- }
+ val projectList = convertEmptyToNull(query.output, write.partitionColumns)
+ val empty2NullPlan = if (projectList.isEmpty) query else
Project(projectList, query)
assert(empty2NullPlan.output.length == query.output.length)
val attrMap = AttributeMap(query.output.zip(empty2NullPlan.output))
-
- // Rewrite the attribute references in the required ordering to use the
new output.
- val requiredOrdering = write.requiredOrdering.map(_.transform {
- case a: Attribute => attrMap.getOrElse(a, a)
- }.asInstanceOf[SortOrder])
Review Comment:
Looks like I was half way there:
https://github.com/apache/spark/pull/38356#issuecomment-1297042658
Only adding this back into the `else` branch below to get to the same `Sort`
was missing in my fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]