-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19602][SQL][TESTS] Add tests for qualified column names #17067
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
Conversation
|
ok to test |
|
Some test cases are negative; some test cases are expected to be supported. Could you split them from the positive test cases? Now some test cases are pretty large. |
|
Test build #73479 has started for PR 17067 at commit |
|
Uh. Forgot one more point. Could you move these test cases to our new end-to-end SQL query suite into |
|
Thank you for working on this! I like the coverage of qualified column names. |
|
retest this please |
|
Test build #73494 has finished for PR 17067 at commit
|
|
We can move the remaining test cases to |
|
Thanks much Xiao for the review and comments. I have made the following changes:
Please advise if we should move any others. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about these test cases for temporary views?
-- Test data.
CREATE OR REPLACE TEMPORARY VIEW testData AS SELECT * FROM VALUES
(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2), (null, 1), (3, null), (null, null)
AS testData(a, b);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me look at converting these too. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also doable for global temporary view, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Xiao, I have moved my new local temp view tests and the global temp view tests to the SQLQueryTestSuite framework as well. Please take a look. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the test cases you want to keep here, you can move it to sql/core. Why we need to test hive serde tables? Compared with data source tables, it is touching different code paths to resolve columns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic to resolve the column in the LogicalPlan is same - there is no change there. I wanted to test the hive table to make sure that the qualifier information is correctly set. We update the qualifier info in MetastoreRelation so wanted to have coverage for hive table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use upper case for SQL keywords.
|
Test build #73561 has finished for PR 17067 at commit
|
e4f347e to
1ae20ec
Compare
|
Test build #73622 has finished for PR 17067 at commit
|
…e out the -ve cases from +ve
…n change in exception
1ae20ec to
5594eb0
Compare
|
|
Test build #73722 has finished for PR 17067 at commit
|
| -- reset | ||
| set spark.sql.crossJoin.enabled = false; | ||
| DROP DATABASE mydb1 CASCADE; | ||
| DROP DATABASE mydb2 CASCADE; No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add one empty space after this line
| SELECT mydb1.t1.i1 FROM t1; | ||
|
|
||
| -- reset | ||
| set spark.sql.crossJoin.enabled = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to line 24
| @@ -0,0 +1,25 @@ | |||
| -- Tests for qualified column names for the view code-path | |||
| -- Test scenario with Temporary view | |||
| CREATE OR REPLACE TEMPORARY VIEW table1 AS SELECT 2 AS i1; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
table1 -> view1
| DROP VIEW table1; | ||
|
|
||
| -- Test scenario with Global Temp view | ||
| CREATE OR REPLACE GLOBAL TEMPORARY VIEW t1 as SELECT 1 as i1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t1 -> view1
| val msg = if (a.plan.nonEmpty) a.getSimpleMessage else a.getMessage | ||
| (StructType(Seq.empty), | ||
| Seq(a.getClass.getName, a.getSimpleMessage.replaceAll("#\\d+", "#x"))) | ||
| Seq(a.getClass.getName, msg.replaceAll("#\\d+", "#x"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: (StructType(Seq.empty), Seq(a.getClass.getName, msg.replaceAll("#\\d+", "#x")))
| struct<> | ||
| -- !query 9 output | ||
| org.apache.spark.sql.AnalysisException | ||
| Reference 't1.i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the other reviewer, this is the reason why we need to make a change in SQLQueryTestSuite.scala
| INSERT INTO t5 VALUES(1, (2, 3)); | ||
| SELECT t5.i1 FROM t5; | ||
| SELECT t5.t5.i1 FROM t5; | ||
| SELECT t5.t5.i1 FROM mydb1.t5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add two more cases for verifying *
|
Generally, it looks good to me. |
|
Test build #73779 has finished for PR 17067 at commit
|
|
LGTM |
|
Thanks! Merging to master. |
|
Thanks a lot Xiao. |
…n name ( 3 part name) ## What changes were proposed in this pull request? The design details is attached to the JIRA issue [here](https://drive.google.com/file/d/1zKm3aNZ3DpsqIuoMvRsf0kkDkXsAasxH/view) High level overview of the changes are: - Enhance the qualifier to be more than one string - Add support to store the qualifier. Enhance the lookupRelation to keep the qualifier appropriately. - Enhance the table matching column resolution algorithm to account for qualifier being more than a string. - Enhance the table matching algorithm in UnresolvedStar.expand - Ensure that we continue to support select t1.i1 from db1.t1 ## How was this patch tested? - New tests are added. - Several test scenarios were added in a separate [test pr 17067](#17067). The tests that were not supported earlier are marked with TODO markers and those are now supported with the code changes here. - Existing unit tests ( hive, catalyst and sql) were run successfully. Closes #17185 from skambha/colResolution. Authored-by: Sunitha Kambhampati <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
How was this patch tested?