Skip to content

Conversation

@gengliangwang
Copy link
Member

@gengliangwang gengliangwang commented Dec 6, 2019

What changes were proposed in this pull request?

Before this PR, the method checkAnswer in Object QueryTest returns 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 method QueryTest.checkAnswer and expect it to fail test cases when the execution results don't match the expected answers.

After this PR:

  1. the method checkAnswer in Object QueryTest will fail tests on errors or unexpected results.
  2. add a new method getErrorMessageInCheckAnswer, which is exactly the same as the previous version of checkAnswer. There are some test suites use this one to customize the test failure message.
  3. for the test suites that extend the trait QueryTest, we should use the method checkAnswer directly, instead of calling the method from Object QueryTest.

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.

@SparkQA
Copy link

SparkQA commented Dec 6, 2019

Test build #114968 has finished for PR 26788 at commit a73fda4.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member

cc @wangyum

@SparkQA
Copy link

SparkQA commented Dec 6, 2019

Test build #114969 has finished for PR 26788 at commit 175f3b9.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gengliangwang
Copy link
Member Author

@wangyum I ran the following command in my local laptop

./build/sbt -Phadoop-2.7 -Phive-2.3 -Pyarn -Phive -Pmesos -Pkinesis-asl -Pspark-ganglia-lgpl -Pkubernetes -Phadoop-cloud -Phive-thriftserver unidoc

and got errors:

[error] /Users/gengliang.wang/Downloads/spark/sql/hive-thriftserver/v2.3/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:248:  error: incompatible types: org.apache.hive.service.rpc.thrift.TSessionHandle cannot be converted to org.apache.hive.service.cli.thrift.TSessionHandle
[error]       resp.setSessionHandle(sessionHandle.toTSessionHandle());
[error]                                                           ^
[error] /Users/gengliang.wang/Downloads/spark/sql/hive-thriftserver/v2.3/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:259:  error: incompatible types: org.apache.hive.service.rpc.thrift.TStatus cannot be converted to org.apache.hive.service.cli.thrift.TStatus
[error]       resp.setStatus(HiveSQLException.toTStatus(e));
[error]                                                ^
[error] /Users/gengliang.wang/Downloads/spark/sql/hive-thriftserver/v2.3/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:346:  error: method getMinVersion in class ThriftCLIService cannot be applied to given types;
[error]     TProtocolVersion protocol = getMinVersion(CLIService.SERVER_VERSION,
[error]   

Any suggestions? Thank you in advance!

@HyukjinKwon
Copy link
Member

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

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.

Copy link
Member Author

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.

@HeartSaVioR
Copy link
Contributor

Looks like dup. of #26768

@gengliangwang
Copy link
Member Author

gengliangwang commented Dec 7, 2019

@wangyum @dongjoon-hyun @HyukjinKwon @HeartSaVioR
I am really sorry I didn't know this is duplicated with #26768 (I even though Doogjoon pinged Yuming for the test failure...)
However, I take a look at #26768 now and I think the code changes in this one are simpler. I also fix some usages which should call the method checkAnswer in the trait QueryTest

@gengliangwang
Copy link
Member Author

retest this please.

@SparkQA
Copy link

SparkQA commented Dec 7, 2019

Test build #114972 has finished for PR 26788 at commit 175f3b9.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@wangyum
Copy link
Member

wangyum commented Dec 7, 2019

Thank you @gengliangwang . I'm close #26768

@wangyum
Copy link
Member

wangyum commented Dec 7, 2019

@wangyum I ran the following command in my local laptop

./build/sbt -Phadoop-2.7 -Phive-2.3 -Pyarn -Phive -Pmesos -Pkinesis-asl -Pspark-ganglia-lgpl -Pkubernetes -Phadoop-cloud -Phive-thriftserver unidoc

and got errors:

[error] /Users/gengliang.wang/Downloads/spark/sql/hive-thriftserver/v2.3/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:248:  error: incompatible types: org.apache.hive.service.rpc.thrift.TSessionHandle cannot be converted to org.apache.hive.service.cli.thrift.TSessionHandle
[error]       resp.setSessionHandle(sessionHandle.toTSessionHandle());
[error]                                                           ^
[error] /Users/gengliang.wang/Downloads/spark/sql/hive-thriftserver/v2.3/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:259:  error: incompatible types: org.apache.hive.service.rpc.thrift.TStatus cannot be converted to org.apache.hive.service.cli.thrift.TStatus
[error]       resp.setStatus(HiveSQLException.toTStatus(e));
[error]                                                ^
[error] /Users/gengliang.wang/Downloads/spark/sql/hive-thriftserver/v2.3/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:346:  error: method getMinVersion in class ThriftCLIService cannot be applied to given types;
[error]     TProtocolVersion protocol = getMinVersion(CLIService.SERVER_VERSION,
[error]   

Any suggestions? Thank you in advance!

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

Choose a reason for hiding this comment

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

Copy link
Member Author

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"]
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 not relevant to this PR. I am trying if the jenkins tests are passed with it.

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

@SparkQA
Copy link

SparkQA commented Dec 7, 2019

Test build #114978 has finished for PR 26788 at commit f824f26.

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

@gengliangwang gengliangwang changed the title [SPARK-30159][SQL][TESTS] Fix the method calls of QueryTest.checkAnswer [WIP][SPARK-30159][SQL][TESTS] Fix the method calls of QueryTest.checkAnswer Dec 7, 2019
@gengliangwang
Copy link
Member Author

mark this one as WIP before #26796 is merged.

}
val expected = Seq(Row(content))
QueryTest.checkAnswer(readContent(), expected)
checkAnswer(readContent, expected)
Copy link
Contributor

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.

@SparkQA
Copy link

SparkQA commented Dec 8, 2019

Test build #114988 has finished for PR 26788 at commit 02c9935.

  • This patch fails Java style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 8, 2019

Test build #114989 has finished for PR 26788 at commit 25fcbb8.

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

@HeartSaVioR
Copy link
Contributor

Retest this, please

@SparkQA
Copy link

SparkQA commented Dec 8, 2019

Test build #114990 has finished for PR 26788 at commit 25fcbb8.

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

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a 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) {
Copy link
Member

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?

Copy link
Contributor

@HeartSaVioR HeartSaVioR Dec 8, 2019

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.

Copy link
Member

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.

@SparkQA
Copy link

SparkQA commented Dec 9, 2019

Test build #114999 has finished for PR 26788 at commit bfbace1.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 9, 2019

Test build #115001 has finished for PR 26788 at commit 6e70776.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

@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.

@SparkQA
Copy link

SparkQA commented Dec 9, 2019

Test build #115000 has finished for PR 26788 at commit 970ec48.

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

@SparkQA
Copy link

SparkQA commented Dec 9, 2019

Test build #115010 has finished for PR 26788 at commit 1384694.

  • This patch fails to generate documentation.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

LGTM

@gengliangwang gengliangwang changed the title [WIP][SPARK-30159][SQL][TESTS] Fix the method calls of QueryTest.checkAnswer [SPARK-30159][SQL][TESTS] Fix the method calls of QueryTest.checkAnswer Dec 9, 2019
@SparkQA
Copy link

SparkQA commented Dec 9, 2019

Test build #115011 has finished for PR 26788 at commit 7fd4057.

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

@gengliangwang
Copy link
Member Author

retest this please.

@SparkQA
Copy link

SparkQA commented Dec 9, 2019

Test build #115018 has finished for PR 26788 at commit 7fd4057.

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

@HyukjinKwon
Copy link
Member

Merged to master.

dongjoon-hyun pushed a commit that referenced this pull request Dec 9, 2019
…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]>
@dongjoon-hyun
Copy link
Member

@HeartSaVioR fixed the lint-java error with the followup (#26818).

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.

8 participants