Skip to content

Conversation

@MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented Nov 11, 2020

What changes were proposed in this pull request?

  1. Create the separate test suite org.apache.spark.sql.hive.execution.command.ShowTablesSuite.
  2. Re-use V1 SHOW TABLES tests added by [SPARK-33382][SQL][TESTS] Unify datasource v1 and v2 SHOW TABLES tests #30287 in the Hive test suites.
  3. Add new test case for the pattern 'table_name_1*|table_name_2*' in the common test suite.

Why are the changes needed?

To test V1 + common SHOW TABLES tests in Hive.

Does this PR introduce any user-facing change?

No

How was this patch tested?

By running v1/v2 and Hive v1 ShowTablesSuite:

$  build/sbt -Phive-2.3 -Phive-thriftserver "test:testOnly *ShowTablesSuite"

@github-actions github-actions bot added the SQL label Nov 11, 2020
@MaxGekk
Copy link
Member Author

MaxGekk commented Nov 11, 2020

@cloud-fan @HyukjinKwon Could you take a look at this PR, please.

@SparkQA
Copy link

SparkQA commented Nov 11, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35553/

@SparkQA
Copy link

SparkQA commented Nov 11, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35553/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Test build #130947 has finished for PR 30340 at commit 4fb6ddc.

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

override protected val spark: SparkSession = TestHive.sparkSession
protected override def beforeAll(): Unit = {}

test("show Hive tables") {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it specific to hive tables? if not we should put it in the base trait.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are not. The difference is probably in omitting explicit USING HIVE.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's not something SHOW TABLES should care about. Let's simply add a test in the base trait for complex patterns and this suite just extends the base trait.

"SHOW TABLES IN default 'show1*'",
ShowRow("default", "show1a", false) :: Nil)
runShowTablesSql(
"SHOW TABLES IN default 'show1*|show2*'",
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 this is the only place that improves test coverage. Maybe we should just add one more test in the base trait to test complicated patterns.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeh, it seems only this test case brings some benefits. Let me move it the common trait, and remove all those duplicate checks.

}

test("show tables with a pattern") {
withNamespace(s"$catalog.ns1", s"$catalog.ns2") {
Copy link
Member Author

Choose a reason for hiding this comment

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

ns2 is not used in the test actually

Copy link
Member Author

Choose a reason for hiding this comment

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

I will revert ns2 back to check that tables from the namespace are not showed.

val df = spark.sql(sqlText)
assert(df.schema === showSchema)
assert(df.collect() === getRows(expected))
assert(df.collect().toSet === getRows(expected).toSet)
Copy link
Member Author

Choose a reason for hiding this comment

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

After modifications in show tables with a pattern, the order of rows was changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

how about checkAnswer(df, getRows(expected))

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced it by checkAnswer()

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Test build #130978 has finished for PR 30340 at commit 8dfd9c7.

  • 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 Nov 12, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35584/

override def version: String = "Hive V1"
override def defaultUsing: String = "USING HIVE"
override protected val spark: SparkSession = TestHive.sparkSession
protected override def beforeAll(): Unit = {}
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to override this otherwise tests failed with:

 SHOW TABLES Hive V1: change current catalog and namespace with USE statements *** FAILED *** (17 milliseconds)
[info]   java.lang.IllegalStateException: LiveListenerBus is stopped.
[info]   at org.apache.spark.scheduler.LiveListenerBus.addToQueue(LiveListenerBus.scala:97)
[info]   at org.apache.spark.scheduler.LiveListenerBus.addToStatusQueue(LiveListenerBus.scala:80)
...
[info]   Cause: java.lang.IllegalStateException: LiveListenerBus is stopped.
[info]   at org.apache.spark.scheduler.LiveListenerBus.addToQueue(LiveListenerBus.scala:97)
[info]   at org.apache.spark.scheduler.LiveListenerBus.addToStatusQueue(LiveListenerBus.scala:80)
[info]   at org.apache.spark.sql.internal.SharedState.<init>(SharedState.scala:103)
[info]   at org.apache.spark.sql.hive.test.TestHiveSharedState.<init>(TestHive.scala:99)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.$anonfun$sharedState$1(TestHive.scala:222)
[info]   at scala.Option.getOrElse(Option.scala:189)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.sharedState$lzycompute(TestHive.scala:222)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.sharedState(TestHive.scala:221)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.sharedState(TestHive.scala:174)
[info]   at org.apache.spark.sql.internal.BaseSessionStateBuilder.build(BaseSessionStateBuilder.scala:333)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.sessionState$lzycompute(TestHive.scala:227)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.sessionState(TestHive.scala:226)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.$anonfun$sql$1(TestHive.scala:240)
[info]   at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:768)
[info]   at org.apache.spark.sql.hive.test.TestHiveSparkSession.sql(TestHive.scala:239)

class ShowTablesSuite extends v1.ShowTablesSuite {
override def version: String = "Hive V1"
override def defaultUsing: String = "USING HIVE"
override protected val spark: SparkSession = TestHive.sparkSession
Copy link
Member Author

Choose a reason for hiding this comment

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

We could take this from TestHiveSingleton but when I mix the trait:

[error] /Users/maximgekk/proj/show-tables-hive-tests/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/ShowTablesSuite.scala:24:7: class ShowTablesSuite inherits conflicting members:
[error]   method spark in trait SharedSparkSessionBase of type => org.apache.spark.sql.SparkSession  and
[error]   value spark in trait TestHiveSingleton of type org.apache.spark.sql.SparkSession
[error] (Note: this can be resolved by declaring an override in class ShowTablesSuite.)
[error] class ShowTablesSuite extends v1.ShowTablesSuite with TestHiveSingleton {
[error]       ^
[error] one error found

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35584/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35590/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35590/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Test build #130984 has finished for PR 30340 at commit fb74566.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait ShowTablesSuite extends QueryTest with SharedSparkSession

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35597/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35600/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35597/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35600/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Test build #130991 has finished for PR 30340 at commit bd0f785.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait ShowTablesSuite extends QueryTest with SQLTestUtils
  • trait ShowTablesTests extends CommonShowTablesSuite
  • class ShowTablesSuite extends CommonShowTablesSuite with SharedSparkSession
  • class ShowTablesSuite extends v1.ShowTablesTests with TestHiveSingleton

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Test build #130994 has finished for PR 30340 at commit 7eab687.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait ShowTablesSuiteBase extends QueryTest with SQLTestUtils
  • case class ShowRow(namespace: String, table: String, isTemporary: Boolean)
  • trait ShowTablesSuiteBase extends command.ShowTablesSuiteBase
  • class ShowTablesSuite extends command.ShowTablesSuiteBase with SharedSparkSession
  • class ShowTablesSuite extends v1.ShowTablesSuiteBase with TestHiveSingleton

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35621/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/35621/

@SparkQA
Copy link

SparkQA commented Nov 12, 2020

Test build #131015 has finished for PR 30340 at commit 7eab687.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait ShowTablesSuiteBase extends QueryTest with SQLTestUtils
  • case class ShowRow(namespace: String, table: String, isTemporary: Boolean)
  • trait ShowTablesSuiteBase extends command.ShowTablesSuiteBase
  • class ShowTablesSuite extends command.ShowTablesSuiteBase with SharedSparkSession
  • class ShowTablesSuite extends v1.ShowTablesSuiteBase with TestHiveSingleton

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 539c2de Nov 13, 2020
@MaxGekk MaxGekk deleted the show-tables-hive-tests branch February 19, 2021 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants