Skip to content

Conversation

@wangyum
Copy link
Member

@wangyum wangyum commented Dec 5, 2019

What changes were proposed in this pull request?

This PR fixes the usage of QueryTest.checkAnswer. It should fail if the results do not match.

Why are the changes needed?

Fix test bug.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

N/A

@SparkQA
Copy link

SparkQA commented Dec 5, 2019

Test build #114904 has finished for PR 26768 at commit d9e6ba9.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Row("5", 2) :: Row("6", 2) :: Row("7", 1) :: Row("8", 1) :: Row("9", 1) :: Nil) match {
case Some(errorMessage) => fail(errorMessage)
case None =>
}
Copy link
Member

@dongjoon-hyun dongjoon-hyun Dec 5, 2019

Choose a reason for hiding this comment

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

This seems to fail like the following at schema comparison.

!== Correct Answer - 9 ==   == Spark Answer - 9 ==
!struct<>                   struct<value:int,count(1):bigint>
 [1,1]                      [1,1]
 [2,1]                      [2,1]
 [3,2]                      [3,2]
 [4,2]                      [4,2]
 [5,2]                      [5,2]
 [6,2]                      [6,2]
 [7,1]                      [7,1]
 [8,1]                      [8,1]
 [9,1]                      [9,1]

Copy link
Member Author

Choose a reason for hiding this comment

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

This is because expectedAnswer's data type do not match. 61eacc9 fix this issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Before this PR. it will not fail.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

countAcc.setValue(0)
QueryTest.checkAnswer(
df, Seq(expectedResult), checkToRDD = false /* avoid duplicate exec */)
df, Seq(expectedResult), checkToRDD = false /* avoid duplicate exec */) match {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not adding a new method in QueryTest object to let it call fail instead? The pattern is simply duplicated across changes, and even QueryTest.checkAnswer (protected method), which warrants enough reason to have another method.

e.g. checkAnswer(df: DataFrame, expectedAnswer: java.util.List[Row]): String

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise, maybe simply call checkAnswer (without QueryTest) - other places in this suite already called like this. Same applies for other suites as well.

@SparkQA
Copy link

SparkQA commented Dec 6, 2019

Test build #114923 has finished for PR 26768 at commit 61eacc9.

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

val caught = intercept[SparkException] {
withSQLConf(SOURCES_BINARY_FILE_MAX_LENGTH.key -> (content.length - 1).toString) {
QueryTest.checkAnswer(readContent(), expected)
QueryTest.checkAnswer(readContent(), expected) match {
Copy link
Member

Choose a reason for hiding this comment

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

Can we ..

  1. make QueryTest.checkAnswer private so that it can only be called in its companion class QueryTest
  2. and avoid to call checkAnswer in the QueryTest object in the tests

?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, basically similar comment with @HeartSaVioR's.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @HyukjinKwon's suggestion would be better for future modification in point of preventing the cause, if there's no actual usage of QueryTest.checkAnswer from outside of QueryTest. (I guess it might have been misused like this PR fixes...)

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