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

    https://github.com/apache/spark/pull/12081#discussion_r59323049
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala ---
    @@ -74,9 +75,18 @@ 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
    +  // This function is to get the path for creating a non-default database
    +  override def getDatabasePath(dbName: String, path: Option[String] = 
None): String = {
    +    val dbPath = path.map(new Path(_)).getOrElse {
    +      val defaultPath = 
context.hiveconf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE)
    +      if (StringUtils.isBlank(defaultPath)) {
    +        throw new AnalysisException(
    +          s"${HiveConf.ConfVars.METASTOREWAREHOUSE.varname} is not set in 
the config or blank")
    +      }
    +      new Path(new Path(defaultPath), dbName.toLowerCase() + ".db")
    +    }
    +    val fs = dbPath.getFileSystem(context.hiveconf)
    +    new Path(fs.getUri.getScheme, fs.getUri.getAuthority, 
dbPath.toUri.getPath).toString
    --- End diff --
    
    Oh, I see. So, at here, we need to make a qualified path because we need to 
make sure that the string stored in the metastore has the scheme (so changing 
the default fs will not affect it), right? If so, can you add comment to 
explain it. If we only use this method to generate the db path and save this 
path in metastore, maybe we can make the name more explicit (something like 
`create...` or `generate...` instead of `get...`)? 
    
    btw, any particular reason that we do not use `fs.makeQualified`? 


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to