Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12081#discussion_r59246954
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala ---
    @@ -74,9 +74,9 @@ private[sql] class HiveSessionCatalog(
       // | Methods and fields for interacting with HiveMetastoreCatalog |
       // ----------------------------------------------------------------
     
    -  override def getDefaultDBPath(db: String): String = {
    -    val defaultPath = 
context.hiveconf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE)
    -    new Path(new Path(defaultPath), db + ".db").toString
    +  override def getDatabasePath(dbName: String, path: Option[String] = 
None): String = {
    +    val dbPath = 
path.getOrElse(context.hiveconf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE))
    +    new Path(new Path(dbPath), dbName.toLowerCase() + ".db").toString
    --- End diff --
    
    The above link points to a wrong function. It should be another function 
`getDefaultDatabasePath `: 
https://github.com/apache/hive/blob/master/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java#L175-L180
    
    Here, we at least miss the verification of 
`HiveConf.ConfVars.METASTOREWAREHOUSE`. If it is blank, we need to issue an 
exception. 
    ```JAVA
        whRootString = HiveConf.getVar(conf, 
HiveConf.ConfVars.METASTOREWAREHOUSE);
        if (StringUtils.isBlank(whRootString)) {
          throw new MetaException(HiveConf.ConfVars.METASTOREWAREHOUSE.varname
              + " is not set in the config or blank");
        }
    ```
    
    Another extreme case is the database `default`. Based on the code, it 
should use the root path. That is, 
`context.hiveconf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE)`, it is not 
using `default.db`. However, hive does not allow users to drop the database 
`default`:
    ```
    hive> drop database default;
    FAILED: Execution Error, return code 1 from 
org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Can not drop 
default database)
    ```
    
    The last piece is `getDnsPath`. Do we need to have and use such a function 
like `getDnsPath`? 
https://github.com/apache/hive/blob/master/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java#L139-L143
 Based on the description, it replace the scheme and authority of a path with 
the scheme and authority of the FileSystem that it maps to. I am not confident 
about this part. I need to do more homework. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to