Skip to content

Conversation

@wangyum
Copy link
Member

@wangyum wangyum commented Oct 7, 2023

What changes were proposed in this pull request?

This PR sets the table's default owner to CURRENT_USER.

Why are the changes needed?

In thrift server mode, the owner of the table is inconsistent with the SELECT CURRENT_USER();, the owner of the table is always the user who started the thrift server.

Does this PR introduce any user-facing change?

The table owner may be changed to CURRENT_USER.

For example:

Before this PR:
yumwang@G9L07H60PK spark-3.5.0-bin-hadoop3 % bin/beeline -u "jdbc:hive2://localhost:10000/" -n test_table_owner -e "create table t(id int) using parquet; desc formatted t;" | grep Owner
Connecting to jdbc:hive2://localhost:10000/
Connected to: Spark SQL (version 3.5.0)
Driver: Hive JDBC (version 2.3.9)
Transaction isolation: TRANSACTION_REPEATABLE_READ
No rows selected (0.36 seconds)
No rows selected (0.1 seconds)
| Owner                         | yumwang                                            |          |
16 rows selected (0.055 seconds)
Beeline version 2.3.9 by Apache Hive
Closing: 0: jdbc:hive2://localhost:10000/

After this PR:
yumwang@G9L07H60PK spark-4.0.0-SNAPSHOT-bin-3.3.6 % bin/beeline -u "jdbc:hive2://localhost:10000/" -n test_table_owner -e "create table t(id int) using parquet; desc formatted t;" | grep Owner
Connecting to jdbc:hive2://localhost:10000/
Connected to: Spark SQL (version 4.0.0-SNAPSHOT)
Driver: Hive JDBC (version 2.3.9)
Transaction isolation: TRANSACTION_REPEATABLE_READ
No rows selected (0.719 seconds)
No rows selected (0.335 seconds)
| Owner                         | test_table_owner                                   |          |
16 rows selected (0.065 seconds)
Beeline version 2.3.9 by Apache Hive
Closing: 0: jdbc:hive2://localhost:10000/

How was this patch tested?

Unit test and manual test.

Was this patch authored or co-authored using generative AI tooling?

No.

Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

LGTM if tests passed.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

Could you re-trigger the failure pipelines, @wangyum ?

@wangyum wangyum force-pushed the SPARK-45454 branch 2 times, most recently from 4c4566b to 7b811f2 Compare October 8, 2023 03:04
@wangyum wangyum changed the title [SPARK-45454][SQL] Set owner of DS v2 table to CURRENT_USER if it is set [SPARK-45454][SQL] Set table owner to current_user Oct 8, 2023
@wangyum wangyum changed the title [SPARK-45454][SQL] Set table owner to current_user [SPARK-45454][SQL] Set the table's default owner to current_user Oct 8, 2023
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM.

@dongjoon-hyun
Copy link
Member

Thank you, @wangyum and @beliefer .
Merged to master for Apache Spark 4.0.0.

@wangyum wangyum deleted the SPARK-45454 branch October 8, 2023 23:41
turboFei pushed a commit to turboFei/spark that referenced this pull request Nov 6, 2025
…ent_user (apache#268)

[SPARK-45454][SQL] Set the table's default owner to current_user

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

This PR sets the table's default owner to `CURRENT_USER`.

### Why are the changes needed?

In thrift server mode, the owner of the table is inconsistent with the `SELECT CURRENT_USER();`,  the owner of the table is always the user who started the thrift server.

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

The table owner may be changed to `CURRENT_USER`.

For example:
```
Before this PR:
yumwangG9L07H60PK spark-3.5.0-bin-hadoop3 % bin/beeline -u "jdbc:hive2://localhost:10000/" -n test_table_owner -e "create table t(id int) using parquet; desc formatted t;" | grep Owner
Connecting to jdbc:hive2://localhost:10000/
Connected to: Spark SQL (version 3.5.0)
Driver: Hive JDBC (version 2.3.9)
Transaction isolation: TRANSACTION_REPEATABLE_READ
No rows selected (0.36 seconds)
No rows selected (0.1 seconds)
| Owner                         | yumwang                                            |          |
16 rows selected (0.055 seconds)
Beeline version 2.3.9 by Apache Hive
Closing: 0: jdbc:hive2://localhost:10000/

After this PR:
yumwangG9L07H60PK spark-4.0.0-SNAPSHOT-bin-3.3.6 % bin/beeline -u "jdbc:hive2://localhost:10000/" -n test_table_owner -e "create table t(id int) using parquet; desc formatted t;" | grep Owner
Connecting to jdbc:hive2://localhost:10000/
Connected to: Spark SQL (version 4.0.0-SNAPSHOT)
Driver: Hive JDBC (version 2.3.9)
Transaction isolation: TRANSACTION_REPEATABLE_READ
No rows selected (0.719 seconds)
No rows selected (0.335 seconds)
| Owner                         | test_table_owner                                   |          |
16 rows selected (0.065 seconds)
Beeline version 2.3.9 by Apache Hive
Closing: 0: jdbc:hive2://localhost:10000/
```

### How was this patch tested?

Unit test and manual test.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#43264 from wangyum/SPARK-45454.

Authored-by: Yuming Wang <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>

(cherry picked from commit 4bad4b6)
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