Skip to content

[SPARK-29405][SQL] Alter table / Insert statements should not change a table's ownership #26068

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 5 commits into from

Conversation

yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented Oct 9, 2019

What changes were proposed in this pull request?

In this change, we give preference to the original table's owner if it is not empty.

Why are the changes needed?

When executing 'insert into/overwrite ...' DML, or 'alter table set tblproperties ...' DDL, spark would change the ownership of the table the one who runs the spark application.

Does this PR introduce any user-facing change?

NO

How was this patch tested?

Compare with the behavior of Apache Hive

@yaooqinn
Copy link
Member Author

cc @wangyum

@wangyum
Copy link
Member

wangyum commented Oct 12, 2019

retest this please

@SparkQA
Copy link

SparkQA commented Oct 12, 2019

Test build #111952 has finished for PR 26068 at commit f408912.

  • 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 Oct 12, 2019

Test build #111964 has finished for PR 26068 at commit a6721ca.

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

@@ -573,8 +574,9 @@ private[hive] class HiveClientImpl(
// If users explicitly alter these Hive-specific properties through ALTER TABLE DDL, we respect
// these user-specified values.
verifyColumnDataType(table.dataSchema)
val owner = Option(table.owner).filter(_.nonEmpty).getOrElse(userName)
Copy link
Member

Choose a reason for hiding this comment

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

Could we move this change to HiveClientImpl.scala#L1043?

Option(table.owner).filter(_.nonEmpty).orElse(userName).foreach(hiveTable.setOwner)

Copy link
Member Author

Choose a reason for hiding this comment

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

It sounds like a bigger deal than it is. Indeed, I am going to add alter table owner syntax, which may make this kind of change back and forth

Copy link
Member

Choose a reason for hiding this comment

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

Hm, yea I think @wangyum's suggestion is more correct.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you @HyukjinKwon Fixed by #26160.

@yaooqinn
Copy link
Member Author

also cc @cloud-fan

@cloud-fan
Copy link
Contributor

how is INSERT TABLE fixed in this PR?

@yaooqinn
Copy link
Member Author

@cloud-fan

CommandUtils.updateTableStats(sparkSession, table)

would eventually call alterTable here

@cloud-fan
Copy link
Contributor

can we add a test in VersionsSuite?

@SparkQA
Copy link

SparkQA commented Oct 17, 2019

Test build #112206 has finished for PR 26068 at commit a990a31.

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

@wangyum
Copy link
Member

wangyum commented Oct 17, 2019

To clarify, this PR fixed the case of ALTER TABLE and INSERT TABLE, but we still have owner issues when creating table: SPARK-29498.

@SparkQA
Copy link

SparkQA commented Oct 17, 2019

Test build #112215 has finished for PR 26068 at commit 10cb13b.

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

@SparkQA
Copy link

SparkQA commented Oct 17, 2019

Test build #112214 has finished for PR 26068 at commit 0743ddd.

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

@cloud-fan
Copy link
Contributor

thanks, merging to master!

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.

LGTM too, though.

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