pan3793 opened a new pull request, #4336:
URL: https://github.com/apache/kyuubi/pull/4336

   <!--
   Thanks for sending a pull request!
   
   Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
https://kyuubi.readthedocs.io/en/latest/community/CONTRIBUTING.html
     2. If the PR is related to an issue in 
https://github.com/apache/kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, 
e.g., '[KYUUBI #XXXX] Your PR title ...'.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][KYUUBI #XXXX] Your PR title ...'.
   -->
   
   ### _Why are the changes needed?_
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you add a feature, you can talk about the use case of it.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   Some DBMS tools like DBeaver and HUE will call thrift meta api for listing 
catalogs, databases, and tables. The current implementation of 
`CatalogShim_v3_0#getSchemas` will call `listAllNamespaces` first and do schema 
pruning on the Spark driver, which may cause "permission denied" exception when 
HMS has permission control, like the ranger plugin.
   
   This PR proposes to call HMS API(through v1 session catalog) directly for 
`spark_catalog`, to suppress the above issue.
   
   ```
   2023-02-15 20:02:13.048 ERROR 
org.apache.kyuubi.server.KyuubiTBinaryFrontendService: Error getting schemas:
   org.apache.kyuubi.KyuubiSQLException: Error operating GetSchemas: 
org.apache.spark.sql.AnalysisException: 
org.apache.hadoop.hive.ql.metadata.HiveException: 
MetaException(message:Permission denied: user [user1] does not have [SELECT] 
privilege on [userdb1])
           at 
org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:134)
           at 
org.apache.spark.sql.hive.HiveExternalCatalog.databaseExists(HiveExternalCatalog.scala:249)
           at 
org.apache.spark.sql.catalyst.catalog.ExternalCatalogWithListener.databaseExists(ExternalCatalogWithListener.scala:69)
           at 
org.apache.spark.sql.catalyst.catalog.SessionCatalog.databaseExists(SessionCatalog.scala:294)
           at 
org.apache.spark.sql.execution.datasources.v2.V2SessionCatalog.listNamespaces(V2SessionCatalog.scala:212)
           at 
org.apache.kyuubi.engine.spark.shim.CatalogShim_v3_0.$anonfun$listAllNamespaces$1(CatalogShim_v3_0.scala:74)
           at 
org.apache.kyuubi.engine.spark.shim.CatalogShim_v3_0.$anonfun$listAllNamespaces$1$adapted(CatalogShim_v3_0.scala:73)
           at 
scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:293)
           at 
scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
           at 
scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
           at 
scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
           at 
scala.collection.TraversableLike.flatMap(TraversableLike.scala:293)
           at 
scala.collection.TraversableLike.flatMap$(TraversableLike.scala:290)
           at 
scala.collection.mutable.ArrayOps$ofRef.flatMap(ArrayOps.scala:198)
           at 
org.apache.kyuubi.engine.spark.shim.CatalogShim_v3_0.listAllNamespaces(CatalogShim_v3_0.scala:73)
           at 
org.apache.kyuubi.engine.spark.shim.CatalogShim_v3_0.listAllNamespaces(CatalogShim_v3_0.scala:90)
           at 
org.apache.kyuubi.engine.spark.shim.CatalogShim_v3_0.getSchemasWithPattern(CatalogShim_v3_0.scala:118)
           at 
org.apache.kyuubi.engine.spark.shim.CatalogShim_v3_0.getSchemas(CatalogShim_v3_0.scala:133)
           at 
org.apache.kyuubi.engine.spark.operation.GetSchemas.runInternal(GetSchemas.scala:43)
           at 
org.apache.kyuubi.operation.AbstractOperation.run(AbstractOperation.scala:164)
           at 
org.apache.kyuubi.session.AbstractSession.runOperation(AbstractSession.scala:99)
           at 
org.apache.kyuubi.engine.spark.session.SparkSessionImpl.runOperation(SparkSessionImpl.scala:78)
           at 
org.apache.kyuubi.session.AbstractSession.getSchemas(AbstractSession.scala:150)
           at 
org.apache.kyuubi.service.AbstractBackendService.getSchemas(AbstractBackendService.scala:83)
           at 
org.apache.kyuubi.service.TFrontendService.GetSchemas(TFrontendService.scala:294)
           at 
org.apache.kyuubi.shade.org.apache.hive.service.rpc.thrift.TCLIService$Processor$GetSchemas.getResult(TCLIService.java:1617)
           at 
org.apache.kyuubi.shade.org.apache.hive.service.rpc.thrift.TCLIService$Processor$GetSchemas.getResult(TCLIService.java:1602)
           at 
org.apache.kyuubi.shade.org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
           at 
org.apache.kyuubi.shade.org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
           at 
org.apache.kyuubi.service.authentication.TSetIpAddressProcessor.process(TSetIpAddressProcessor.scala:36)
           at 
org.apache.kyuubi.shade.org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:286)
           at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
           at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
           at java.lang.Thread.run(Thread.java:750)
   ```
   
   ### _How was this patch tested?_
   - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
   
   - [ ] Add screenshots for manual tests if appropriate
   
   - [ ] [Run 
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
 locally before make a pull request
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to