[SPARK-31262][SQL][TESTS] Fix bug tests imported bracketed comments#28018
[SPARK-31262][SQL][TESTS] Fix bug tests imported bracketed comments#28018beliefer wants to merge 1 commit intoapache:masterfrom
Conversation
|
Test build #120329 has finished for PR 28018 at commit
|
|
Test build #120341 has finished for PR 28018 at commit
|
| */ | ||
| SELECT 'selected content' AS first; | ||
| --QUERY-DELIMITER-END | ||
| --IMPORT nested-comments.sql |
There was a problem hiding this comment.
What did this means?
Golden files can't display well.
There was a problem hiding this comment.
I updated the description to Golden files can't display the bracketed comments in imported test cases.
There was a problem hiding this comment.
Also, could you put an output example before/after this PR in the PR description?
There was a problem hiding this comment.
OK. I have put the output example
| val input = fileToString(new File(testCase.inputFile)) | ||
|
|
||
| val (comments, code) = input.split("\n").partition { line => | ||
| def splitCommentsAndCodes(input: String) = input.split("\n").partition { line => |
|
I think this issue is worth filing a new jira. |
OK. I created a new JIRA and update the title of this PR. |
| -- the first case of bracketed comment | ||
| --QUERY-DELIMITER-START | ||
| /* This is the first example of bracketed comment. | ||
| SELECT 'ommented out content' AS first; |
There was a problem hiding this comment.
This is not a nested comment, right?
There was a problem hiding this comment.
This is a bracketed comments.
Maybe I need change nested-comments.sql to imported-comments.sql?
There was a problem hiding this comment.
maybe updating SQLQueryTestSuite only is good enough. It's an obvious bug that we forget to handle QUERY-DELIMITER in imported code.
There was a problem hiding this comment.
You means I shouldn't change comments.sql and add nested-comments.sql ?
There was a problem hiding this comment.
yea, it's not necessary to separate this test file.
There was a problem hiding this comment.
OK. I will revert it.
cec4670 to
fddcbe0
Compare
fddcbe0 to
1e60d83
Compare
|
Test build #120419 has finished for PR 28018 at commit
|
|
Test build #120420 has finished for PR 28018 at commit
|
### What changes were proposed in this pull request? This PR related to #27481. If test case A uses `--IMPORT` to import test case B contains bracketed comments, the output can't display bracketed comments in golden files well. The content of `nested-comments.sql` show below: ``` -- This test case just used to test imported bracketed comments. -- the first case of bracketed comment --QUERY-DELIMITER-START /* This is the first example of bracketed comment. SELECT 'ommented out content' AS first; */ SELECT 'selected content' AS first; --QUERY-DELIMITER-END ``` The test case `comments.sql` imports `nested-comments.sql` below: `--IMPORT nested-comments.sql` Before this PR, the output will be: ``` -- !query /* This is the first example of bracketed comment. SELECT 'ommented out content' AS first -- !query schema struct<> -- !query output org.apache.spark.sql.catalyst.parser.ParseException mismatched input '/' expecting {'(', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', ' ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 0) == SQL == /* This is the first example of bracketed comment. ^^^ SELECT 'ommented out content' AS first -- !query */ SELECT 'selected content' AS first -- !query schema struct<> -- !query output org.apache.spark.sql.catalyst.parser.ParseException extraneous input '*/' expecting {'(', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', 'ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 0) == SQL == */ ^^^ SELECT 'selected content' AS first ``` After this PR, the output will be: ``` -- !query /* This is the first example of bracketed comment. SELECT 'ommented out content' AS first; */ SELECT 'selected content' AS first -- !query schema struct<first:string> -- !query output selected content ``` ### Why are the changes needed? Golden files can't display the bracketed comments in imported test cases. ### Does this PR introduce any user-facing change? 'No'. ### How was this patch tested? New UT. Closes #28018 from beliefer/fix-bug-tests-imported-bracketed-comments. Authored-by: beliefer <beliefer@163.com> Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org> (cherry picked from commit 9e0fee9) Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
|
Thanks! Merged to master/3.0. |
|
@maropu @cloud-fan @dongjoon-hyun Thanks for all. |
### What changes were proposed in this pull request? This PR related to apache#27481. If test case A uses `--IMPORT` to import test case B contains bracketed comments, the output can't display bracketed comments in golden files well. The content of `nested-comments.sql` show below: ``` -- This test case just used to test imported bracketed comments. -- the first case of bracketed comment --QUERY-DELIMITER-START /* This is the first example of bracketed comment. SELECT 'ommented out content' AS first; */ SELECT 'selected content' AS first; --QUERY-DELIMITER-END ``` The test case `comments.sql` imports `nested-comments.sql` below: `--IMPORT nested-comments.sql` Before this PR, the output will be: ``` -- !query /* This is the first example of bracketed comment. SELECT 'ommented out content' AS first -- !query schema struct<> -- !query output org.apache.spark.sql.catalyst.parser.ParseException mismatched input '/' expecting {'(', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', ' ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 0) == SQL == /* This is the first example of bracketed comment. ^^^ SELECT 'ommented out content' AS first -- !query */ SELECT 'selected content' AS first -- !query schema struct<> -- !query output org.apache.spark.sql.catalyst.parser.ParseException extraneous input '*/' expecting {'(', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', 'ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 0) == SQL == */ ^^^ SELECT 'selected content' AS first ``` After this PR, the output will be: ``` -- !query /* This is the first example of bracketed comment. SELECT 'ommented out content' AS first; */ SELECT 'selected content' AS first -- !query schema struct<first:string> -- !query output selected content ``` ### Why are the changes needed? Golden files can't display the bracketed comments in imported test cases. ### Does this PR introduce any user-facing change? 'No'. ### How was this patch tested? New UT. Closes apache#28018 from beliefer/fix-bug-tests-imported-bracketed-comments. Authored-by: beliefer <beliefer@163.com> Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
What changes were proposed in this pull request?
This PR related to #27481.
If test case A uses
--IMPORTto import test case B contains bracketed comments, the output can't display bracketed comments in golden files well.The content of
nested-comments.sqlshow below:The test case
comments.sqlimportsnested-comments.sqlbelow:--IMPORT nested-comments.sqlBefore this PR, the output will be:
After this PR, the output will be:
Why are the changes needed?
Golden files can't display the bracketed comments in imported test cases.
Does this PR introduce any user-facing change?
'No'.
How was this patch tested?
New UT.