-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-17011][SQL] Support testing exceptions in SQLQueryTestSuite #14592
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| -- limit on various data types | ||
| select * from testdata limit 2; | ||
| select * from arraydata limit 2; | ||
| select * from mapdata limit 2; | ||
|
|
||
| -- foldable non-literal in limit | ||
| select * from testdata limit 2 + 1; | ||
|
|
||
| select * from testdata limit CAST(1 AS int); | ||
|
|
||
| -- limit must be non-negative | ||
| select * from testdata limit -1; | ||
|
|
||
| -- limit must be foldable | ||
| select * from testdata limit key > 3; | ||
|
|
||
| -- limit must be integer | ||
| select * from testdata limit true; | ||
| select * from testdata limit 'a'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 9 | ||
|
|
||
|
|
||
| -- !query 0 | ||
| select * from testdata limit 2 | ||
| -- !query 0 schema | ||
| struct<key:int,value:string> | ||
| -- !query 0 output | ||
| 1 1 | ||
| 2 2 | ||
|
|
||
|
|
||
| -- !query 1 | ||
| select * from arraydata limit 2 | ||
| -- !query 1 schema | ||
| struct<arraycol:array<int>,nestedarraycol:array<array<int>>> | ||
| -- !query 1 output | ||
| [1,2,3] [[1,2,3]] | ||
| [2,3,4] [[2,3,4]] | ||
|
|
||
|
|
||
| -- !query 2 | ||
| select * from mapdata limit 2 | ||
| -- !query 2 schema | ||
| struct<mapcol:map<int,string>> | ||
| -- !query 2 output | ||
| {1:"a1",2:"b1",3:"c1",4:"d1",5:"e1"} | ||
| {1:"a2",2:"b2",3:"c2",4:"d2"} | ||
|
|
||
|
|
||
| -- !query 3 | ||
| select * from testdata limit 2 + 1 | ||
| -- !query 3 schema | ||
| struct<key:int,value:string> | ||
| -- !query 3 output | ||
| 1 1 | ||
| 2 2 | ||
| 3 3 | ||
|
|
||
|
|
||
| -- !query 4 | ||
| select * from testdata limit CAST(1 AS int) | ||
| -- !query 4 schema | ||
| struct<key:int,value:string> | ||
| -- !query 4 output | ||
| 1 1 | ||
|
|
||
|
|
||
| -- !query 5 | ||
| select * from testdata limit -1 | ||
| -- !query 5 schema | ||
| struct<> | ||
| -- !query 5 output | ||
| org.apache.spark.sql.AnalysisException | ||
| The limit expression must be equal to or greater than 0, but got -1; | ||
|
|
||
|
|
||
| -- !query 6 | ||
| select * from testdata limit key > 3 | ||
| -- !query 6 schema | ||
| struct<> | ||
| -- !query 6 output | ||
| org.apache.spark.sql.AnalysisException | ||
| The limit expression must evaluate to a constant value, but got (testdata.`key` > 3); | ||
|
|
||
|
|
||
| -- !query 7 | ||
| select * from testdata limit true | ||
| -- !query 7 schema | ||
| struct<> | ||
| -- !query 7 output | ||
| org.apache.spark.sql.AnalysisException | ||
| The limit expression must be integer type, but got boolean; | ||
|
|
||
|
|
||
| -- !query 8 | ||
| select * from testdata limit 'a' | ||
| -- !query 8 schema | ||
| struct<> | ||
| -- !query 8 output | ||
| org.apache.spark.sql.AnalysisException | ||
| The limit expression must be integer type, but got string; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| -- Automatically generated by org.apache.spark.sql.SQLQueryTestSuite | ||
| -- Number of queries: 4 | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 5 | ||
|
|
||
|
|
||
| -- !query 0 | ||
|
|
@@ -19,16 +19,24 @@ struct<2147483648:bigint,(-2147483649):bigint> | |
|
|
||
|
|
||
| -- !query 2 | ||
| select 9223372036854775808, -9223372036854775809 | ||
| select 9223372036854775807, -9223372036854775808 | ||
| -- !query 2 schema | ||
| struct<9223372036854775808:decimal(19,0),(-9223372036854775809):decimal(19,0)> | ||
| struct<9223372036854775807:bigint,(-9223372036854775808):decimal(19,0)> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "-9223372036854775808" is a valid long value (Long.MinValue) but Spark treats it as a decimal(19, 0) because "9223372036854775808" is out of range. Is this expected? cc @cloud-fan
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also cc @sarutak who wrote the original test case.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a parser bug? cc @hvanhovell
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd call this a bug. I tried in Spark 1.6 and it was returning double (which was worse). Here's postgres:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @petermaxlee can you file a jira ticket for this bug?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| -- !query 2 output | ||
| 9223372036854775808 -9223372036854775809 | ||
| 9223372036854775807 -9223372036854775808 | ||
|
|
||
|
|
||
| -- !query 3 | ||
| select 0.3, -0.8, .5, -.18, 0.1111 | ||
| select 9223372036854775808, -9223372036854775809 | ||
| -- !query 3 schema | ||
| struct<0.3:decimal(1,1),(-0.8):decimal(1,1),0.5:decimal(1,1),(-0.18):decimal(2,2),0.1111:decimal(4,4)> | ||
| struct<9223372036854775808:decimal(19,0),(-9223372036854775809):decimal(19,0)> | ||
| -- !query 3 output | ||
| 9223372036854775808 -9223372036854775809 | ||
|
|
||
|
|
||
| -- !query 4 | ||
| select 0.3, -0.8, .5, -.18, 0.1111 | ||
| -- !query 4 schema | ||
| struct<0.3:decimal(1,1),(-0.8):decimal(1,1),0.5:decimal(1,1),(-0.18):decimal(2,2),0.1111:decimal(4,4)> | ||
| -- !query 4 output | ||
| 0.3 -0.8 0.5 -0.18 0.1111 | ||
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.
can you also add the boundary conditions for int as well?
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.
Can I add it in a separate pull request? I want to add all literal parsing here, but don't want to distract this pull request.
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.
sgtm