Skip to content

Conversation

@Peng-Lei
Copy link
Contributor

@Peng-Lei Peng-Lei commented Nov 3, 2021

What changes were proposed in this pull request?

  1. Move SHOW TBLPROPERTIES parsing tests to ShowTblPropertiesParserSuite.
  2. Define the class command.ShowTblPropertiesSuiteBase that is parent of v1.ShowTblPropertiesSuiteBase and v2.ShowTblPropertiesSuite.
  3. Define the class v1.ShowTblPropertiesSuiteBase that is parent of v1.ShowTblPropertiesSuite and hive.execution.command.ShowTblPropertiesSuite.
  4. move test case from DataSourceV2SQLSessionCatalogSuite to command.ShowTblPropertiesSuiteBase to run for V2/V1/HIVE V1
  5. move some test case from HiveCommandSuite to command.ShowTblPropertiesSuiteBase
  6. move some test case from HiveCommandSuite to v1.ShowTblPropertiesSuiteBase to run for V1/HIVE V1
  7. Add two test case for v1.ShowTblPropertiesSuite for view.

The changes follow the approach of #30287 #34305

Why are the changes needed?

  1. The unification will allow to run common SHOW TBLPROPERTIES tests for both DSv1/Hive DSv1 and DSv2
  2. We can detect missing features and differences between DSv1 and DSv2 implementations.

Does this PR introduce any user-facing change?

No

How was this patch tested?

By running v1/v2 and Hive v1 ShowTblPropertiesSuite:

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

@github-actions github-actions bot added the SQL label Nov 3, 2021
@Peng-Lei
Copy link
Contributor Author

Peng-Lei commented Nov 3, 2021

I'm not sure that
L1229 should move to ShowTblPropertiesParserSuite, because it is test Resolve not Parser and we should move some method more if do it. @MaxGekk @imback82 @cloud-fan

@SparkQA
Copy link

SparkQA commented Nov 3, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 3, 2021

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

Copy link
Member

@MaxGekk MaxGekk left a comment

Choose a reason for hiding this comment

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

L1229 should move to ShowTblPropertiesParserSuite, because it is test Resolve not Parser

@Peng-Lei If you have such tests, please, place them to a separate test suite but not to *ParserSuite. Actually, I planned to do so if I would work on unifying of v1 and v2 CREATE TABLE tests.

@SparkQA
Copy link

SparkQA commented Nov 3, 2021

Test build #144876 has finished for PR 34476 at commit b66d351.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class ShowTblPropertiesParserSuite extends AnalysisTest
  • trait ShowTblPropertiesSuiteBase extends QueryTest with DDLCommandTestUtils
  • class ShowTblPropertiesSuite extends ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesSuite extends command.ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesSuite extends v1.ShowTblPropertiesSuiteBase with CommandSuiteBase

@Peng-Lei
Copy link
Contributor Author

Peng-Lei commented Nov 4, 2021

If you have such tests, please, place them to a separate test suite but not to *ParserSuite. Actually, I planned to do so if I would work on unifying of v1 and v2 CREATE TABLE tests.

@MaxGekk , Could you continue to look at it, and I made the following modifications

  1. I define the PlanResolutionSuiteBase that contains the properties and methods of PlanResolutionSuite.
  2. Define the v1.ShowTblPropertiesPlanResolutionSuite and v2.ShowTblPropertiesPlanResolutionSuite extends the PlanResolutionSuiteBase, so that they can use method of parent class.
  3. In order to guarantee PlanResolutionSuite is right that after extract method/properties to properties , I change that PlanResolutionSuite extends PlanResolutionSuiteBase.
  4. PlanResolutionSuiteBase may not be abstract enough, but enough for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave this suite unchanged.

Today we have a unified framework to resolve database objects in commands, and we don't need to test plan resolution for each command. We will probably clean up this test suite to only test DML commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Today we have a unified framework to resolve database objects in commands, and we don't need to test plan resolution for each command.

Thank you for reminding me, you're quite right. I will undo the last modification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@SparkQA
Copy link

SparkQA commented Nov 4, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 4, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 4, 2021

Test build #144895 has finished for PR 34476 at commit 2806dfd.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class PlanResolutionSuite extends PlanResolutionSuiteBase
  • class PlanResolutionSuiteBase extends AnalysisTest
  • class ShowTblPropertiesParserSuite extends AnalysisTest
  • trait ShowTblPropertiesSuiteBase extends QueryTest with DDLCommandTestUtils
  • class ShowTblPropertiesPlanResolutionSuite extends PlanResolutionSuiteBase
  • class ShowTblPropertiesSuite extends ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesPlanResolutionSuite extends PlanResolutionSuiteBase
  • class ShowTblPropertiesSuite extends command.ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesSuite extends v1.ShowTblPropertiesSuiteBase with CommandSuiteBase

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

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

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 possible to unify the test? seems this PR just move the old tests to either v1 or v2 test suite, but did not unify them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hold on. Let me think more and learn more about #30287 #34305

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

Test build #145091 has finished for PR 34476 at commit 95a2266.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class ShowTblPropertiesParserSuite extends AnalysisTest
  • trait ShowTblPropertiesSuiteBase extends QueryTest with DDLCommandTestUtils
  • class ShowTblPropertiesSuite extends ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesSuite extends command.ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesSuite extends v1.ShowTblPropertiesSuiteBase with CommandSuiteBase

@cloud-fan
Copy link
Contributor

are you going to unify the tests? @Peng-Lei

@Peng-Lei
Copy link
Contributor Author

Peng-Lei commented Nov 15, 2021

are you going to unify the tests? @Peng-Lei

Yeah. I am going work on this. Sorry. I clicked the wrong request for review. @cloud-fan

spark.sql(s"CREATE TABLE $tbl (id bigint, data string) $defaultUsing " +
s"TBLPROPERTIES ('user'='$user', 'status'='$status')")

val properties = sql(s"SHOW TBLPROPERTIES $tbl").filter("key != 'transient_lastDdlTime'")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to be compatible Hive table, so add the filter action.


val properties = sql(s"SHOW TBLPROPERTIES $tbl ('$nonExistingKey')")
val expected = Seq(Row(nonExistingKey,
s"Table ns1.tbl does not have property: $nonExistingKey"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The table name without catalog name in V1 different with V2.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we change the test code so that it can be moved to the base class? e.g.

val res = properties.collect()
assert(res.length == 1)
assert(res.head.getString(0) == nonExistingKey)
assert(res.head.getString(1).contains("does not have property: $nonExistingKey"))

withNamespaceAndTable("ns1", "tbl") { tbl =>
spark.sql(s"CREATE TABLE $tbl (id bigint, data string) $defaultUsing " +
s"TBLPROPERTIES ('user'='andrew', 'status'='new')")
withSQLConf(SQLConf.LEGACY_KEEP_COMMAND_OUTPUT_SCHEMA.key -> "true") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In V1. We can set LEGACY_KEEP_COMMAND_OUTPUT_SCHEMA to control the output.

@Peng-Lei
Copy link
Contributor Author

update as follow:

  • move test case from DataSourceV2SQLSessionCatalogSuite to command.ShowTblPropertiesSuiteBase to run for V2/V1/HIVE V1
  • move some test case from HiveCommandSuite to command.ShowTblPropertiesSuiteBase
  • move some test case from HiveCommandSuite to v1.ShowTblPropertiesSuiteBase to run for V1/HIVE V1
  • Add two test case for v1.ShowTblPropertiesSuite for view.

@SparkQA
Copy link

SparkQA commented Nov 16, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 16, 2021

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

Row("user", user))

assert(properties.schema === schema)
assert(expected === properties.collect().sortBy(_.toString))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we can use checkAnswer to check result


val properties = sql(s"SHOW TBLPROPERTIES $tbl ('status')")
val expected = Seq(Row("status", status))
assert(expected === properties.collect())
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

class ShowTblPropertiesSuite extends ShowTblPropertiesSuiteBase with CommandSuiteBase {
override def commandVersion: String = super[ShowTblPropertiesSuiteBase].commandVersion

test("SHOW TBLPROPERTIES FOR VIEW") {
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason to have these 2 tests here is because hive can return more properties?

Copy link
Contributor

Choose a reason for hiding this comment

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

if so can we add a comment to explain it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason to have these 2 tests here is because hive can return more properties?

Yeah. An additional attribute transient_lastDdlTime is added for hive. I try to move the test case to v1.base with filter the properties transient_lastDdlTime. So they can run for V1/HIVE V1

Copy link
Contributor

@cloud-fan cloud-fan left a comment

Choose a reason for hiding this comment

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

LGTM except for some minor comments

@SparkQA
Copy link

SparkQA commented Nov 16, 2021

Test build #145277 has finished for PR 34476 at commit a6db08e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class ShowTblPropertiesParserSuite extends AnalysisTest
  • trait ShowTblPropertiesSuiteBase extends QueryTest with DDLCommandTestUtils
  • class ShowTblPropertiesSuite extends ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesSuite extends command.ShowTblPropertiesSuiteBase with CommandSuiteBase
  • class ShowTblPropertiesSuite extends v1.ShowTblPropertiesSuiteBase with CommandSuiteBase

Row("user", user))

assert(properties.schema === schema)
checkAnswer(properties.sort("key"), expected)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

v2: sort the result. v1: without the sort. So the test case sort the result before the compare

Copy link
Contributor

Choose a reason for hiding this comment

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

v1 should sort as well. We can fix this in a followup.

@SparkQA
Copy link

SparkQA commented Nov 17, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 17, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 17, 2021

Test build #145325 has finished for PR 34476 at commit 95e30cf.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class ShowTblPropertiesSuite extends ShowTblPropertiesSuiteBase with CommandSuiteBase

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 06586f6 Nov 17, 2021
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.

4 participants