-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-30159][SQL][TESTS] Fix the method calls of QueryTest.checkAnswer
#26788
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
Conversation
|
Test build #114968 has finished for PR 26788 at commit
|
|
cc @wangyum |
|
Test build #114969 has finished for PR 26788 at commit
|
|
@wangyum I ran the following command in my local laptop and got errors: Any suggestions? Thank you in advance! |
|
Is it a duplicate of #26768? |
| * @param expectedAnswer the expected result in a [[Seq]] of [[Row]]s. | ||
| * @param checkToRDD whether to verify deserialization to an RDD. This runs the query twice. | ||
| */ | ||
| def checkAnswer(df: DataFrame, expectedAnswer: Seq[Row], checkToRDD: Boolean = true): Unit = { |
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.
We can make it private if this isn't supposed to be called in the tests directly. companion class still can access.
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.
There are some suites needs this one: ReduceNumShufflePartitionsSuite, SessionStateSuite and SQLQuerySuite(SQLQuerySuite needs to set the parameter checkToRDD as false)
And I prefer not to have duplicated code in these 3 suites.
|
Looks like dup. of #26768 |
|
@wangyum @dongjoon-hyun @HyukjinKwon @HeartSaVioR |
|
retest this please. |
|
Test build #114972 has finished for PR 26788 at commit
|
|
Thank you @gengliangwang . I'm close #26768 |
Cloud you try: ./build/sbt clean -Phadoop-2.7 -Phive-2.3 -Pyarn -Phive -Pmesos -Pkinesis-asl -Pspark-ganglia-lgpl -Pkubernetes -Phadoop-cloud -Phive-thriftserver unidoc |
| QueryTest.checkAnswer(spark.table("counts").toDF(), | ||
| checkAnswer(spark.table("counts").toDF(), | ||
| Row("1", 1) :: Row("2", 1) :: Row("3", 2) :: Row("4", 2) :: | ||
| Row("5", 2) :: Row("6", 2) :: Row("7", 1) :: Row("8", 1) :: Row("9", 1) :: Nil) |
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.
This should fail because the types do not match: https://github.com/apache/spark/pull/26768/files#r354499485
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.
Got it, thanks!
dev/run-tests.py
Outdated
| # Enable all of the profiles for the build: | ||
| build_profiles = extra_profiles + modules.root.build_profile_flags | ||
| sbt_goals = ["unidoc"] | ||
| sbt_goals = ["clean", "unidoc"] |
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.
This is not relevant to this PR. I am trying if the jenkins tests are passed with it.
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.
Nice. It passed now. Could you make a new PR for this line first?
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.
Sure
|
Test build #114978 has finished for PR 26788 at commit
|
QueryTest.checkAnswerQueryTest.checkAnswer
|
mark this one as WIP before #26796 is merged. |
sql/core/src/test/scala/org/apache/spark/sql/execution/ReduceNumShufflePartitionsSuite.scala
Outdated
Show resolved
Hide resolved
| } | ||
| val expected = Seq(Row(content)) | ||
| QueryTest.checkAnswer(readContent(), expected) | ||
| checkAnswer(readContent, expected) |
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.
nit: maybe either removing () from function or roll back the change of removing ()? It's not just retrieving the value, adding () seems to be semantically correct.
|
Test build #114988 has finished for PR 26788 at commit
|
|
Test build #114989 has finished for PR 26788 at commit
|
|
Retest this, please |
|
Test build #114990 has finished for PR 26788 at commit
|
HeartSaVioR
left a comment
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.
LGTM
| private static void checkAnswer(Dataset<Row> actual, List<Row> expected) { | ||
| String errorMessage = QueryTest$.MODULE$.checkAnswer(actual, expected); | ||
| String errorMessage = QueryTest$.MODULE$.getErrorMessageInCheckAnswer(actual, expected); | ||
| if (errorMessage != null) { |
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.
This construction seems kinda pointless then. Why not just let checkAnswer fail with an assertion, rather than have a separate method that only returns the error and have tests manually check if there's an error string and fail it?
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.
If there's no issue on calling fail from scalatest in java suite (mixed-up usage), that seems the way to go; otherwise we may be able to have another QueryTest as utility class for java suite, and move this method instead and reuse across java suites.
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.
I think it's OK; it will generate a relevant failure exception and message. I'd prefer it for simplicity.
|
Test build #114999 has finished for PR 26788 at commit
|
|
Test build #115001 has finished for PR 26788 at commit
|
|
@gengliangwang, can you try to pick 8c06512 and see if it works here? I checked in local but wanted to be very sure it fixes. |
6e70776 to
1384694
Compare
|
Test build #115000 has finished for PR 26788 at commit
|
|
Test build #115010 has finished for PR 26788 at commit
|
1384694 to
7fd4057
Compare
|
LGTM |
QueryTest.checkAnswerQueryTest.checkAnswer
|
Test build #115011 has finished for PR 26788 at commit
|
|
retest this please. |
|
Test build #115018 has finished for PR 26788 at commit
|
|
Merged to master. |
…mports ### What changes were proposed in this pull request? This patch fixes the Java code style violations in SPARK-30159 (#26788) which are caught by lint-java (Github Action caught it and I can reproduce it locally). Looks like Jenkins build may have different policy on checking Java style check or less accurate. ### Why are the changes needed? Java linter starts complaining. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? lint-java passed locally This closes #26819 Closes #26818 from HeartSaVioR/SPARK-30159-FOLLOWUP. Authored-by: Jungtaek Lim (HeartSaVioR) <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
|
@HeartSaVioR fixed the lint-java error with the followup (#26818). |
What changes were proposed in this pull request?
Before this PR, the method
checkAnswerin ObjectQueryTestreturns an optional string. It doesn't throw exceptions when errors happen.The actual exceptions are thrown in the trait
QueryTest.However, there are some test suites(
StreamSuite,SessionStateSuite,BinaryFileFormatSuite, etc.) that use the no-op methodQueryTest.checkAnswerand expect it to fail test cases when the execution results don't match the expected answers.After this PR:
checkAnswerin ObjectQueryTestwill fail tests on errors or unexpected results.getErrorMessageInCheckAnswer, which is exactly the same as the previous version ofcheckAnswer. There are some test suites use this one to customize the test failure message.QueryTest, we should use the methodcheckAnswerdirectly, instead of calling the method from ObjectQueryTest.Why are the changes needed?
We should fix these method calls to perform actual validations in test suites.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing unit tests.