[SPARK-28617][SQL][TEST] Fix misplacement when comment is at the end of the query#25357
[SPARK-28617][SQL][TEST] Fix misplacement when comment is at the end of the query#25357wangyum wants to merge 6 commits intoapache:masterfrom wangyum:SPARK-28617
Conversation
| val input = fileToString(new File(testCase.inputFile)) | ||
|
|
||
| val (comments, code) = input.split("\n").partition(_.startsWith("--")) | ||
| val (comments, codeMaybeWithComment) = input.split("\n").partition(_.trim.startsWith("--")) |
There was a problem hiding this comment.
Add trim to filter out these comments:
|
|
||
| val (comments, code) = input.split("\n").partition(_.startsWith("--")) | ||
| val (comments, codeMaybeWithComment) = input.split("\n").partition(_.trim.startsWith("--")) | ||
| val code = codeMaybeWithComment.map(_.split("--").head) |
There was a problem hiding this comment.
Add split to fix these comments error:
Comment for SELECT date '5874898-01-01':
But the golden file is:
spark/sql/core/src/test/resources/sql-tests/results/pgSQL/date.sql.out
Lines 484 to 507 in a5a5da7
There was a problem hiding this comment.
oh... really weird output... nice catch.
|
Although there is a side effect, this PR seems to have a bigger positive side than a negative side. I'm supporting this approach, @wangyum . cc @gatorsmile , @maropu , @HyukjinKwon |
| -- !query 2 | ||
| SELECT | ||
| -- boolean or transitions | ||
| -- null because strict |
There was a problem hiding this comment.
Thanks for doing udf-* test cases too.
|
+1 too |
|
Test build #108639 has finished for PR 25357 at commit
|
|
|
||
| val (comments, code) = input.split("\n").partition(_.startsWith("--")) | ||
| val (comments, codeMaybeWithComment) = input.split("\n").partition(_.trim.startsWith("--")) | ||
| val code = codeMaybeWithComment.map(_.split("--").head) |
There was a problem hiding this comment.
@wangyum . Is it safe with a query like SELECT '12--34'?
- val code = codeMaybeWithComment.map(_.split("--").head)
dongjoon-hyun
left a comment
There was a problem hiding this comment.
In this new approach, could you fix the new corner case like the following?
Input
SELECT '12--34'
Output
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 1
-- !query 0
SELECT '12
-- !query 0 schema
struct<>
-- !query 0 output
org.apache.spark.sql.catalyst.parser.ParseException
no viable alternative at input 'SELECT ''(line 1, pos 7)
== SQL ==
SELECT '12
-------^^^
|
+1, too |
|
Test build #108695 has finished for PR 25357 at commit
|
|
Test build #108710 has finished for PR 25357 at commit
|
| -- !query 1 | ||
| -- Case 5 | ||
| -- (one null column with no match -> row is returned) | ||
| -- (one null column with no match -> row is returned) |
There was a problem hiding this comment.
Also, can we remove this too?
|
Test build #108754 has finished for PR 25357 at commit
|
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM. Thank you for fixing this, @wangyum .
Thank you, @HyukjinKwon and @maropu .
Merged to master.
What changes were proposed in this pull request?
This PR fixes the issue of misplacement when the comment at the end of the query. Example:
Comment for
SELECT date '5874898-01-01':spark/sql/core/src/test/resources/sql-tests/inputs/pgSQL/date.sql
Line 200 in 2d74f14
But the golden file is:
spark/sql/core/src/test/resources/sql-tests/results/pgSQL/date.sql.out
Lines 484 to 507 in a5a5da7
After this PR:
spark/sql/core/src/test/resources/sql-tests/results/pgSQL/date.sql.out
Lines 482 to 501 in eeb7405
How was this patch tested?
N/A