1、hive meta server使用sentry權限認證,kyuubi在opensession的時候初始化默認數據庫會報空指針異常
問題版本:0.8
原因:hive metahook過濾元數據的時候需要從配置中獲取用戶名,屬性名是hive.sentry.subject.name,但是在sparkcontext初始化的時候並沒有設置該屬性
解決方案:在sparkcontext初始化的時候設置參數
在kyuubi項目中的類SparkSessionWithUGI的newContext方法中添加如下代碼:
conf.set("hive.access.subject.name", userName)
conf.set("hive.sentry.subject.name", userName)
修改後的代碼爲:
private lazy val newContext: Thread = {
val threadName = "SparkContext-Starter-" + userName
new Thread(threadName) {
override def run(): Unit = promisedSparkContext.complete(Try {
if (SparkEnv.get != null) {
Thread.sleep(2000)
}
conf.set("hive.access.subject.name", userName)
conf.set("hive.sentry.subject.name", userName)
new SparkContext(conf)
})
}
}