Skip to content
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

[MINOR] Follow up for SPARK-23936, fixed description of "map_concat" function #23493

Closed

Conversation

asiunov
Copy link

@asiunov asiunov commented Jan 9, 2019

What changes were proposed in this pull request?

The description of "map_concat" function does not correspond to the actual behavior. Unit tests, an example in shell, and the PR description (https://jira.apache.org/jira/browse/SPARK-23936, #21073) say that duplicated keys will be duplicated, but the function description says the opposite.

scala> spark.sql("SELECT map_concat(map(1, 'a', 2, 'b'), map(2, 'c', 3, 'd'))").show(20, false)
+--------------------------------------------+
|map_concat(map(1, a, 2, b), map(2, c, 3, d))|
+--------------------------------------------+
|[1 -> a, 2 -> b, 2 -> c, 3 -> d]            |
+--------------------------------------------+

Looks like it was implemented correctly in the original PR, but then incorrectly changed in this PR: #22437

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@@ -516,7 +516,7 @@ case class MapEntries(child: Expression) extends UnaryExpression with ExpectsInp
examples = """
Examples:
> SELECT _FUNC_(map(1, 'a', 2, 'b'), map(2, 'c', 3, 'd'));
{1:"a",2:"c",3:"d"}
{1:"a",2:"b",2:"c",3:"d"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which spark version did you use? Duplicated entries were fixed and it shows:

spark-sql> SELECT map_concat(map(1, 'a', 2, 'b'), map(2, 'c', 3, 'd'));
{1:"a",2:"c",3:"d"}

and

scala> spark.sql("SELECT map_concat(map(1, 'a', 2, 'b'), map(2, 'c', 3, 'd'))").show(20, false)
+--------------------------------------------+
|map_concat(map(1, a, 2, b), map(2, c, 3, d))|
+--------------------------------------------+
|[1 -> a, 2 -> c, 3 -> d]                    |
+--------------------------------------------+

in the current master.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Looks like I've tested on v2.4.0 because my SPARK_HOME targeted to the old repo, and the logic was changed towards to exclude duplicates in #23124 .
Now I'm checking on the latest master and have the same results as yours.
Thank you!

@asiunov asiunov closed this Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants