Skip to content

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

Closed
yaooqinn wants to merge 5 commits into
apache:masterfrom
yaooqinn:SPARK-29405
Closed

[SPARK-29405][SQL] Alter table / Insert statements should not change a table's ownership#26068
yaooqinn wants to merge 5 commits into
apache:masterfrom
yaooqinn:SPARK-29405

Conversation

@yaooqinn

@yaooqinn yaooqinn commented Oct 9, 2019

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

cc @wangyum

@wangyum

wangyum commented Oct 12, 2019

Copy link
Copy Markdown
Member

retest this please

@SparkQA

SparkQA commented Oct 12, 2019

Copy link
Copy Markdown

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

SparkQA commented Oct 12, 2019

Copy link
Copy Markdown

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.

// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

also cc @cloud-fan

@cloud-fan

Copy link
Copy Markdown
Contributor

how is INSERT TABLE fixed in this PR?

@yaooqinn

Copy link
Copy Markdown
Member Author

@cloud-fan

CommandUtils.updateTableStats(sparkSession, table)

would eventually call alterTable here

@cloud-fan

Copy link
Copy Markdown
Contributor

can we add a test in VersionsSuite?

@SparkQA

SparkQA commented Oct 17, 2019

Copy link
Copy Markdown

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.

Comment thread sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala Outdated
@wangyum

wangyum commented Oct 17, 2019

Copy link
Copy Markdown
Member

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

SparkQA commented Oct 17, 2019

Copy link
Copy Markdown

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

SparkQA commented Oct 17, 2019

Copy link
Copy Markdown

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
Copy Markdown
Contributor

thanks, merging to master!

@HyukjinKwon HyukjinKwon left a comment

Copy link
Copy Markdown
Member

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