Skip to content
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

[SPARK-32405][SQL] Apply table options while creating tables in JDBC Table Catalog #30154

Closed
wants to merge 8 commits into from

Conversation

huaxingao
Copy link
Contributor

What changes were proposed in this pull request?

Currently in JDBCTableCatalog, we ignore the table options when creating table.

    // TODO (SPARK-32405): Apply table options while creating tables in JDBC Table Catalog
    if (!properties.isEmpty) {
      logWarning("Cannot create JDBC table with properties, these properties will be " +
        "ignored: " + properties.asScala.map { case (k, v) => s"$k=$v" }.mkString("[", ", ", "]"))
    }

Why are the changes needed?

need to apply the table options when we create table

Does this PR introduce any user-facing change?

no

How was this patch tested?

add new test

@SparkQA
Copy link

SparkQA commented Oct 26, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 26, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 27, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 27, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 27, 2020

Test build #130302 has finished for PR 30154 at commit edf98d0.

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

@huaxingao
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Oct 27, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 27, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 27, 2020

Test build #130306 has finished for PR 30154 at commit edf98d0.

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

@@ -123,8 +123,14 @@ class JDBCTableCatalog extends TableCatalog with Logging {
"ignored: " + properties.asScala.map { case (k, v) => s"$k=$v" }.mkString("[", ", ", "]"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't removed the Warning yet. The properties here could be provider, owner, location, comment or TBLPROPERTIES key value pairs. I only implemented comment. Seems to me these are not options in standard database CREATE TABLE syntax. I am not sure if we need to support all of them.

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 a more reasonable behavior is to fail if unsupported table properties are given. JDBC V2 is new in this release so we still have a chance to change it.

For these 4 builtin properties, I think we only need to support comment. We should ignore provider for now. And after the CRETE TABLE unification, we can force users to not specify USING when creating table in JDBC v2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, so we will support comment and ignore provider, owner, and location for now.

For supported table properties, do we need to make them database specific? for example, ENGINE and CHARSET are supported table properties for MySQL but not supported by other databases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of having a complete list of supported table properties for each of the databases, it might be better to send whatever table properties without checking and let it fail at database side if unsupported.

Copy link
Contributor

Choose a reason for hiding this comment

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

yea, that sounds better, although it needs more work to update every dialect.

@huaxingao
Copy link
Contributor Author

@cloud-fan
Copy link
Contributor

We also need to retrieve the table comment in TableCatalog.loadTable

@huaxingao
Copy link
Contributor Author

We also need to retrieve the table comment in TableCatalog.loadTable

So we will retrieve table comment using a query and then set this comment in JDBCOptions in JDBCTable, right? This query is different for different databases, for example, MySQL has SELECT table_comment FROM INFORMATION_SCHEMA.TABLES WHERE table_name='tablename', DB2 has SELECT remarks from syscat.tables where tabname='tablename'

@cloud-fan
Copy link
Contributor

This query is different for different databases

ah, it's so complicated. Let's forget about it for this PR.

@SparkQA
Copy link

SparkQA commented Oct 31, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 31, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 31, 2020

Test build #130480 has finished for PR 30154 at commit 74469a6.

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

@huaxingao
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Oct 31, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 31, 2020

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

@SparkQA
Copy link

SparkQA commented Oct 31, 2020

Test build #130485 has finished for PR 30154 at commit 74469a6.

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

@SparkQA
Copy link

SparkQA commented Nov 3, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 3, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 3, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 3, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 5, 2020

Test build #130640 has finished for PR 30154 at commit bb9c4fc.

  • 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 5, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 5, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 6, 2020

Test build #130670 has finished for PR 30154 at commit 39057aa.

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

case "provider" =>
case "owner" => // owner is ignored. It is default to current user name.
case "location" =>
throw new AnalysisException("Cannot create JDBC table with property location.")
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 be more user-facing: CREATE TABLE ... LOCATION ... is not supported in the JDBC catalog.

@SparkQA
Copy link

SparkQA commented Nov 6, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 6, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 6, 2020

Test build #130696 has finished for PR 30154 at commit ecc9a4e.

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

@huaxingao
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Nov 6, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 6, 2020

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

@SparkQA
Copy link

SparkQA commented Nov 6, 2020

Test build #130731 has finished for PR 30154 at commit ecc9a4e.

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

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in bfb257f Nov 9, 2020
@huaxingao
Copy link
Contributor Author

Thank you! @cloud-fan

@huaxingao huaxingao deleted the table_options branch November 9, 2020 17:09
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