[SPARK-31166][SQL] UNION map<null, null> and other maps should not fail#27926
Closed
cloud-fan wants to merge 1 commit into
Closed
[SPARK-31166][SQL] UNION map<null, null> and other maps should not fail#27926cloud-fan wants to merge 1 commit into
cloud-fan wants to merge 1 commit into
Conversation
Contributor
Author
|
Test build #119875 has finished for PR 27926 at commit
|
maropu
reviewed
Mar 17, 2020
| checkAnswer( | ||
| sql("(SELECT map()) UNION ALL (SELECT map(1, 2))"), | ||
| Seq(Row(Map[Int, Int]()), Row(Map(1 -> 2)))) | ||
| } |
Member
There was a problem hiding this comment.
Nice catch! It seems #27542 broke some other queries merging map<null,null> and map<some type, some type>, e.g., map_concat;
// the current master
scala> sql("select map_concat(map(), map(1, 2))").show()
org.apache.spark.sql.AnalysisException: cannot resolve 'map_concat(map(), map(1, 2))' due to data type mismatch: input to function map_concat should all be the same type, but it's [map<null,null>, map<int,int>]; line 1 pos 7;
'Project [unresolvedalias(map_concat(map(), map(1, 2)), None)]
+- OneRowRelation
at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
This PR can fix this query, too.
maropu
approved these changes
Mar 17, 2020
Contributor
Author
|
thanks for review, merging to master/3.0! |
cloud-fan
added a commit
that referenced
this pull request
Mar 17, 2020
After #27542, `map()` returns `map<null, null>` instead of `map<string, string>`. However, this breaks queries which union `map()` and other maps. The reason is, `TypeCoercion` rules and `Cast` think it's illegal to cast null type map key to other types, as it makes the key nullable, but it's actually legal. This PR fixes it. To avoid breaking queries. Yes, now some queries that work in 2.x can work in 3.0 as well. new test Closes #27926 from cloud-fan/bug. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit d7b97a1) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
HyukjinKwon
added a commit
that referenced
this pull request
Mar 24, 2020
…lex and Cast.canCast in null <> complex types ### What changes were proposed in this pull request? This PR (SPARK-31229) is rather a followup of #27926 (SPARK-31166). It adds unittests for `TypeCoercion.findTypeForComplex` and `Cast.canCast` about struct, map and array with the respect to null types. ### Why are the changes needed? To detect which scope was broken in the future easily. ### Does this PR introduce any user-facing change? No, it's a test-only. ### How was this patch tested? Unittests were added. Closes #27990 from HyukjinKwon/SPARK-31166-followup. Authored-by: HyukjinKwon <gurwls223@apache.org> Signed-off-by: HyukjinKwon <gurwls223@apache.org>
HyukjinKwon
added a commit
that referenced
this pull request
Mar 24, 2020
…lex and Cast.canCast in null <> complex types ### What changes were proposed in this pull request? This PR (SPARK-31229) is rather a followup of #27926 (SPARK-31166). It adds unittests for `TypeCoercion.findTypeForComplex` and `Cast.canCast` about struct, map and array with the respect to null types. ### Why are the changes needed? To detect which scope was broken in the future easily. ### Does this PR introduce any user-facing change? No, it's a test-only. ### How was this patch tested? Unittests were added. Closes #27990 from HyukjinKwon/SPARK-31166-followup. Authored-by: HyukjinKwon <gurwls223@apache.org> Signed-off-by: HyukjinKwon <gurwls223@apache.org> (cherry picked from commit bd32400) Signed-off-by: HyukjinKwon <gurwls223@apache.org>
sjincho
pushed a commit
to sjincho/spark
that referenced
this pull request
Apr 15, 2020
### What changes were proposed in this pull request? After apache#27542, `map()` returns `map<null, null>` instead of `map<string, string>`. However, this breaks queries which union `map()` and other maps. The reason is, `TypeCoercion` rules and `Cast` think it's illegal to cast null type map key to other types, as it makes the key nullable, but it's actually legal. This PR fixes it. ### Why are the changes needed? To avoid breaking queries. ### Does this PR introduce any user-facing change? Yes, now some queries that work in 2.x can work in 3.0 as well. ### How was this patch tested? new test Closes apache#27926 from cloud-fan/bug. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
sjincho
pushed a commit
to sjincho/spark
that referenced
this pull request
Apr 15, 2020
…lex and Cast.canCast in null <> complex types ### What changes were proposed in this pull request? This PR (SPARK-31229) is rather a followup of apache#27926 (SPARK-31166). It adds unittests for `TypeCoercion.findTypeForComplex` and `Cast.canCast` about struct, map and array with the respect to null types. ### Why are the changes needed? To detect which scope was broken in the future easily. ### Does this PR introduce any user-facing change? No, it's a test-only. ### How was this patch tested? Unittests were added. Closes apache#27990 from HyukjinKwon/SPARK-31166-followup. Authored-by: HyukjinKwon <gurwls223@apache.org> Signed-off-by: HyukjinKwon <gurwls223@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
After #27542,
map()returnsmap<null, null>instead ofmap<string, string>. However, this breaks queries which unionmap()and other maps.The reason is,
TypeCoercionrules andCastthink it's illegal to cast null type map key to other types, as it makes the key nullable, but it's actually legal. This PR fixes it.Why are the changes needed?
To avoid breaking queries.
Does this PR introduce any user-facing change?
Yes, now some queries that work in 2.x can work in 3.0 as well.
How was this patch tested?
new test