Skip to content

[SPARK-29498][SQL] CatalogTable to HiveTable should not change the table's ownership #26160

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

Closed
wants to merge 2 commits into from
Closed

Conversation

wangyum
Copy link
Member

@wangyum wangyum commented Oct 18, 2019

What changes were proposed in this pull request?

CatalogTable to HiveTable will change the table's ownership. How to reproduce:

import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.catalog.{CatalogStorageFormat, CatalogTable, CatalogTableType}
import org.apache.spark.sql.types.{LongType, StructType}

val identifier = TableIdentifier("spark_29498", None)
val owner = "SPARK-29498"
val newTable = CatalogTable(
  identifier,
  tableType = CatalogTableType.EXTERNAL,
  storage = CatalogStorageFormat(
    locationUri = None,
    inputFormat = None,
    outputFormat = None,
    serde = None,
    compressed = false,
    properties = Map.empty),
  owner = owner,
  schema = new StructType().add("i", LongType, false),
  provider = Some("hive"))

spark.sessionState.catalog.createTable(newTable, false)
// The owner is not SPARK-29498
println(spark.sessionState.catalog.getTableMetadata(identifier).owner)

This PR makes it set the HiveTable's owner to CatalogTable's owner if it's owner is not empty when converting CatalogTable to HiveTable.

Why are the changes needed?

We should not change the ownership of the table when converting CatalogTable to HiveTable.

Does this PR introduce any user-facing change?

No

How was this patch tested?

unit test

@SparkQA
Copy link

SparkQA commented Oct 18, 2019

Test build #112271 has finished for PR 26160 at commit 86d8325.

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

@SparkQA
Copy link

SparkQA commented Oct 18, 2019

Test build #112274 has finished for PR 26160 at commit 507fced.

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

@wangyum
Copy link
Member Author

wangyum commented Oct 18, 2019

cc @yaooqinn @cloud-fan

@yaooqinn
Copy link
Member

IIUC, the ownership of a table only be created/changed(#26068) when we create or alter a table.
CreateTable - the owner <=> the creator <=> the spark runner
AlterTable - the original owner or the spark runner if none or empty
So I guess both cases are handled with or without this change.

SPARK-29507, We now just lack the ability to modify the owner of a table.

@wangyum
Copy link
Member Author

wangyum commented Oct 18, 2019

I think the owner of the HiveTable is always the same as the owner of the CatalogTable if the owner of the CatalogTable is not empty.

This is how we convert HiveTable to CatalogTable:

@yaooqinn
Copy link
Member

Anyway, this change can keep the consistency of ownership between catalog table and hive table, so LGTM

@dongjoon-hyun
Copy link
Member

cc @gatorsmile

@cloud-fan cloud-fan closed this in e99a9f7 Oct 21, 2019
@cloud-fan
Copy link
Contributor

LGTM, merging to master!

@wangyum wangyum deleted the SPARK-29498 branch October 21, 2019 07:56
@dongjoon-hyun
Copy link
Member

Thank you, @cloud-fan , @wangyum .
Since this is a bug reported for the old releases, can we have this in our LTS branch, branch-2.4, too?

dongjoon-hyun pushed a commit that referenced this pull request Oct 25, 2019
…he table's ownership

### What changes were proposed in this pull request?

This PR backport #26160 to branch-2.4.

### Why are the changes needed?
Backport from master.

### Does this PR introduce any user-facing change?
No.

### How was this patch tested?
unit test

Closes #26248 from wangyum/SPARK-29498-branch-2.4.

Authored-by: Yuming Wang <yumwang@ebay.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Thanks @wangyum. Looks fine to me too

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.

6 participants