-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-41959][SQL] Improve v1 writes with empty2null #39475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,13 +93,8 @@ 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)) | ||
|
||
|
@@ -108,7 +103,6 @@ object V1Writes extends Rule[LogicalPlan] with SQLConfHelper { | |
case a: Attribute => attrMap.getOrElse(a, a) | ||
}.asInstanceOf[SortOrder]) | ||
val outputOrdering = query.outputOrdering | ||
// Check if the ordering is already matched to ensure the idempotency of the rule. | ||
val orderingMatched = isOrderingMatched(requiredOrdering, outputOrdering) | ||
if (orderingMatched) { | ||
empty2NullPlan | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if we don't add the sort here, the caller will rewrite the attributes in v1 command which will update required orderng expression as well, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, that's the root reason in |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check has no meaning now since we have already checked
WriteFiles
for rule idempotency.