[SPARK-30082][SQL] Depend on Scala type coercion when building replace query #628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
apache#26738
apache#26749
What changes were proposed in this pull request?
Depend on type coercion when building the replace query. This would solve an edge case where when trying to replace
NaNs,0s would get replace too.Why are the changes needed?
This Scala code snippet:
returns
0which is problematic as if you run the following Spark code,0s get replaced as well:Does this PR introduce any user-facing change?
Yes, after the PR, running the same above code snippet returns the correct expected results:
And additionally, query results are changed as a result of the change in depending on scala's type coercion rules.
How was this patch tested?
Added unit tests to verify replacing
NaNonly affects columns of typeFloatandDouble.