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

[SPARK-17685][SQL] Make SortMergeJoinExec's currentVars is null when calling createJoinKey #15259

Closed
wants to merge 1 commit into from

Conversation

wangyum
Copy link
Member

@wangyum wangyum commented Sep 27, 2016

What changes were proposed in this pull request?

The following SQL query cause IndexOutOfBoundsException issue when LIMIT > 1310720:

CREATE TABLE tab1(int int, int2 int, str string);
CREATE TABLE tab2(int int, int2 int, str string);
INSERT INTO tab1 values(1,1,'str');
INSERT INTO tab1 values(2,2,'str');
INSERT INTO tab2 values(1,1,'str');
INSERT INTO tab2 values(2,3,'str');

SELECT
  count(*)
FROM
  (
    SELECT t1.int, t2.int2 
    FROM (SELECT * FROM tab1 LIMIT 1310721) t1
    INNER JOIN (SELECT * FROM tab2 LIMIT 1310721) t2 
    ON (t1.int = t2.int AND t1.int2 = t2.int2)
  ) t;

This pull request fix this issue.

How was this patch tested?

New test case added in DataFrameJoinSuite.

@SparkQA
Copy link

SparkQA commented Sep 27, 2016

Test build #65963 has finished for PR 15259 at commit 2bb54b5.

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

@hvanhovell
Copy link
Contributor

hvanhovell commented Sep 27, 2016

@wangyum could you explain what causes this problem?

@wangyum
Copy link
Member Author

wangyum commented Sep 28, 2016

@hvanhovell

The following SQL query thrown IndexOutOfBoundsException:

SELECT
  count(int)
FROM
  (
    SELECT t1.int, t2.int2 
    FROM (SELECT * FROM tab1 LIMIT 1310721) t1
    INNER JOIN (SELECT * FROM tab2 LIMIT 1310721) t2 
    ON (t1.int = t2.int AND t1.int2 = t2.int2)
  ) t;

SortMergeJoinExec.createJoinKey()‘sctx.currentVars is the expression of count(int), keys is the join condition int and int2, as shown in the following screenshot:
indexoutofboundsexception1


ordinal is the key's index of keys when constructingBoundReference, as shown in the following screenshot:
indexoutofboundsexception2


So ctx.currentVars(ordinal)(ordinal=1) will throw IndexOutOfBoundsException when doGenCode, as shown in the following screenshot:
indexoutofboundsexception3


I think ctx.currentVars have nothing to do with keys at this time, so I want to set ctx.currentVars=null to avoid IndexOutOfBoundsException.

@wangyum
Copy link
Member Author

wangyum commented May 9, 2017

@hvanhovell I updated PR description.

@wangyum
Copy link
Member Author

wangyum commented May 9, 2017

Jenkins, retest this please

@SparkQA
Copy link

SparkQA commented May 9, 2017

Test build #76610 has finished for PR 15259 at commit 2bb54b5.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 9, 2017

Test build #76645 has started for PR 15259 at commit 2bb54b5.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76645/
Test FAILed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants