Skip to content

[SPARK-28617][SQL][TEST] Fix misplacement when comment is at the end of the query#25357

Closed
wangyum wants to merge 6 commits intoapache:masterfrom
wangyum:SPARK-28617
Closed

[SPARK-28617][SQL][TEST] Fix misplacement when comment is at the end of the query#25357
wangyum wants to merge 6 commits intoapache:masterfrom
wangyum:SPARK-28617

Conversation

@wangyum
Copy link
Member

@wangyum wangyum commented Aug 5, 2019

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':

SELECT date '5874898-01-01'; -- out of range

But the golden file is:
-- !query 46
-- out of range
SELECT f1 - date '2000-01-01' AS `Days From 2K` FROM DATE_TBL
-- !query 46 schema
struct<Days From 2K:int>
-- !query 46 output
-1035
-1036
-1037
-1400
-1401
-1402
-1403
-15542
-15607
13977
14343
14710
91
92
93

After this PR:

-- !query 46
SELECT f1 - date '2000-01-01' AS `Days From 2K` FROM DATE_TBL
-- !query 46 schema
struct<Days From 2K:int>
-- !query 46 output
-1035
-1036
-1037
-1400
-1401
-1402
-1403
-15542
-15607
13977
14343
14710
91
92
93

How was this patch tested?

N/A

val input = fileToString(new File(testCase.inputFile))

val (comments, code) = input.split("\n").partition(_.startsWith("--"))
val (comments, codeMaybeWithComment) = input.split("\n").partition(_.trim.startsWith("--"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add split to fix these comments error:
Comment for SELECT date '5874898-01-01':

SELECT date '5874898-01-01'; -- out of range

But the golden file is:
-- !query 46
-- out of range
SELECT f1 - date '2000-01-01' AS `Days From 2K` FROM DATE_TBL
-- !query 46 schema
struct<Days From 2K:int>
-- !query 46 output
-1035
-1036
-1037
-1400
-1401
-1402
-1403
-15542
-15607
13977
14343
14710
91
92
93

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... really weird output... nice catch.

@dongjoon-hyun
Copy link
Member

dongjoon-hyun commented Aug 5, 2019

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing udf-* test cases too.

@HyukjinKwon
Copy link
Member

+1 too

@SparkQA
Copy link

SparkQA commented Aug 5, 2019

Test build #108639 has finished for PR 25357 at commit 523c426.

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


val (comments, code) = input.split("\n").partition(_.startsWith("--"))
val (comments, codeMaybeWithComment) = input.split("\n").partition(_.trim.startsWith("--"))
val code = codeMaybeWithComment.map(_.split("--").head)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangyum . Is it safe with a query like SELECT '12--34'?

- val code = codeMaybeWithComment.map(_.split("--").head)

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
-------^^^

@maropu
Copy link
Member

maropu commented Aug 6, 2019

+1, too

@wangyum wangyum changed the title [SPARK-28617][SQL][TEST] Completely remove comments from the golden result file [SPARK-28617][SQL][TEST] Fix misplacement when comment is at the end of the query Aug 6, 2019
@SparkQA
Copy link

SparkQA commented Aug 6, 2019

Test build #108695 has finished for PR 25357 at commit eeb7405.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 6, 2019

Test build #108710 has finished for PR 25357 at commit a9abe00.

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

-- !query 1
-- Case 5
-- (one null column with no match -> row is returned)
-- (one null column with no match -> row is returned)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can we remove this too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be removed by #25357 (comment)

@SparkQA
Copy link

SparkQA commented Aug 7, 2019

Test build #108754 has finished for PR 25357 at commit 60e38af.

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

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Thank you for fixing this, @wangyum .
Thank you, @HyukjinKwon and @maropu .
Merged to master.

@wangyum wangyum deleted the SPARK-28617 branch August 8, 2019 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants