-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22846][SQL] Fix table owner is null when creating table through spark sql or thriftserver #20034
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-22846][SQL] Fix table owner is null when creating table through spark sql or thriftserver #20034
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,7 +186,7 @@ private[hive] class HiveClientImpl( | |
| /** Returns the configuration for the current session. */ | ||
| def conf: HiveConf = state.getConf | ||
|
|
||
| private val userName = state.getAuthenticator.getUserName | ||
| private val userName = conf.getUser | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BruceXu1991. I want to reproduce your problem here. Could you describe your environment more specifically? For me, 2.2.1 works like the following. scala> spark.version
res0: String = 2.2.1
scala> sql("CREATE TABLE spark_22846(a INT)")
scala> sql("DESCRIBE FORMATTED spark_22846").show
+--------------------+--------------------+-------+
| col_name| data_type|comment|
+--------------------+--------------------+-------+
| a| int| null|
| | | |
|# Detailed Table ...| | |
| Database| default| |
| Table| spark_22846| |
| Owner| dongjoon| |
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, does this happen in case of MySQL as Hive metastore?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I met this problem by using MySQL as Hive metastore. '''
''' and the detail stack info: this result of NPE is that owner is null. The relevant source code is below:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you know how Hive get the username internally?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for your response, Fan. now the current implementation of spark-2.2.1 is when the implementation of state.getAuthenticator is HadoopDefaultAuthenticator, which is default in hive conf, the username is got. however, in the case that the implementation of state.getAuthenticator is SessionStateUserAuthenticator, which is used in my case, then username will be null. the simplified code below explains the reason:
it shows that HadoopDefaultAuthenticator will get username through Utils.getUGI(), so the username is HADOOP_USER_NAME or LoginUser.
it shows that SessionStateUserAuthenticator get the username through sessionState.getUserName(), which is null, because username is not used in the instantiation of sessionState. Here is the instantiation of SessionState in HiveClientImpl So getting username through conf.getUser may be more compatible to various use case. the related code in HiveConf: |
||
|
|
||
| override def getConf(key: String, defaultValue: String): String = { | ||
| conf.get(key, defaultValue) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this returns null?