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-37496][SQL] Migrate ReplaceTableAsSelectStatement to v2 command #34754

Closed
wants to merge 2 commits into from

Conversation

huaxingao
Copy link
Contributor

What changes were proposed in this pull request?

This PR migrates ReplaceTableAsSelectStatement to the v2 command

Why are the changes needed?

Migrate to the standard V2 framework

Does this PR introduce any user-facing change?

No

How was this patch tested?

existing tests

@github-actions github-actions bot added the SQL label Nov 30, 2021
@SparkQA
Copy link

SparkQA commented Nov 30, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 30, 2021

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

@SparkQA
Copy link

SparkQA commented Nov 30, 2021

Test build #145757 has finished for PR 34754 at commit 3323d2e.

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

@huaxingao
Copy link
Contributor Author

cc @cloud-fan Could you please take a look?

extraOptions.toMap,
None,
orCreate = true) // Create the table if it doesn't exist
val tableSpec = TableSpec(None, Map.empty, Some(source), Map.empty,
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 use named parameter here: TableSpec(bucketSpec = None, ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

options.toMap,
None,
orCreate = orCreate))
val tableSpec = TableSpec(None, properties.toMap, provider, Map.empty,
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

writeOptions: CaseInsensitiveStringMap,
orCreate: Boolean,
invalidateCache: (TableCatalog, Table, Identifier) => Unit) extends TableWriteExecHelper {

val properties = {
val props = CatalogV2Util.convertTableProperties(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should the util function take TableSpec directly? and also fill the ownership property. Then we can simplify the code here and other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

@SparkQA
Copy link

SparkQA commented Dec 1, 2021

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

serde = None,
external = false)
ReplaceTableAsSelect(
UnresolvedDBObjectName(nameParts, isNamespace = false),
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we prepend catalog.name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems no need? I stepped into one of the test, the nameParts here is "testcat", "ns", "t", so it already contains catalog.name.

@SparkQA
Copy link

SparkQA commented Dec 1, 2021

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

@SparkQA
Copy link

SparkQA commented Dec 1, 2021

Test build #145820 has finished for PR 34754 at commit ecc596c.

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

@huaxingao huaxingao closed this in f97de30 Dec 1, 2021
@huaxingao
Copy link
Contributor Author

Merged to master. Thank you very much for reviewing! @cloud-fan

@huaxingao huaxingao deleted the replace_table branch December 1, 2021 23:46
orCreate = true) // Create the table if it doesn't exist
df.queryExecution.analyzed,
tableSpec,
writeOptions = Map.empty,
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 there is a bug here. Previously we pass extraOptions.toMap as the write options, now we don't. @huaxingao can you help to fix it with a test case? thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the bug. Will fix.

cloud-fan pushed a commit that referenced this pull request Dec 27, 2021
…write options in CTAS and RTAS

### What changes were proposed in this pull request?
`DataFrameWriter.saveAsTable` should pass `extraOptions.toMap` as the write options in CTAS and RTAS

### Why are the changes needed?
bug fixing
please see #34754 (comment) #34667 (comment)

### Does this PR introduce _any_ user-facing change?
no

### How was this patch tested?
new test

Closes #34997 from huaxingao/write_option.

Authored-by: Huaxin Gao <huaxin_gao@apple.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants