Skip to content

[SPARK-12395] [SQL] fix resulting columns of outer join - #10353

Closed
davies wants to merge 1 commit into
apache:masterfrom
davies:fix_join
Closed

[SPARK-12395] [SQL] fix resulting columns of outer join#10353
davies wants to merge 1 commit into
apache:masterfrom
davies:fix_join

Conversation

@davies

Copy link
Copy Markdown
Contributor

For API DataFrame.join(right, usingColumns, joinType), if the joinType is right_outer or full_outer, the resulting join columns could be wrong (will be null).

The order of columns had been changed to match that with MySQL and PostgreSQL [1].

This PR also fix the nullability of output for outer join.

[1] http://www.postgresql.org/docs/9.2/static/queries-table-expressions.html

@davies

Copy link
Copy Markdown
ContributorAuthor

cc @rxin@liancheng

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Here we can use an AttributeSet for convenience:

valjoinRefs=AttributeSet(condition.toSeq.flatMap(_.references))
valresultCols= joinedCols ++ joined.output.filterNot(joinRefs.contains)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Maybe not, as the comment said, we can't compare Attribute here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but that is exactly what an AttributeSet is for. It is a set that only compares the id.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@liancheng@marmbrus Oh, I see, missed that, thanks!

@liancheng

Copy link
Copy Markdown
Contributor

LGTM except for one minor issue.

@SparkQA

Copy link
Copy Markdown

Test build #47914 has finished for PR 10353 at commit f5ab9cb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@yhuai

Copy link
Copy Markdown
Contributor

Does 1.5 have this problem?

@davies

Copy link
Copy Markdown
ContributorAuthor

@yhuai No, this is a new feature in 1.6

asfgit pushed a commit that referenced this pull request Dec 17, 2015
For API DataFrame.join(right, usingColumns, joinType), if the joinType is right_outer or full_outer, the resulting join columns could be wrong (will be null).
The order of columns had been changed to match that with MySQL and PostgreSQL [1].
This PR also fix the nullability of output for outer join.
[1] http://www.postgresql.org/docs/9.2/static/queries-table-expressions.html
Author: Davies Liu <davies@databricks.com>
Closes#10353 from davies/fix_join.
(cherry picked from commit a170d34)
Signed-off-by: Davies Liu <davies.liu@gmail.com>
Sign up for freeto 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.

5 participants

@davies@liancheng@SparkQA@yhuai@marmbrus