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

    https://github.com/apache/spark/pull/14139#discussion_r70727924
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
    @@ -273,6 +273,22 @@ private[hive] class HiveMetastoreCatalog(val client: 
ClientInterface, hive: Hive
             serdeProperties = options)
         }
     
    +    def hasPartitionColumns(relation: BaseRelation): Boolean = relation 
match {
    +      case hadoopFsRelation: HadoopFsRelation =>
    +        try {
    +          // Calling hadoopFsRelation.partitionColumns will trigger the 
refresh call of
    +          // the HadoopFsRelation, which will validate input paths. 
However, when we create
    +          // an empty table, the dir of the table has not been created, 
which will
    +          // cause a FileNotFoundException. So, at here we will catch the 
FileNotFoundException
    +          // and return false.
    +          hadoopFsRelation.partitionColumns.nonEmpty
    +        } catch {
    +          case _: java.io.FileNotFoundException =>
    +            false
    +        }
    +      case _ => false
    +    }
    --- End diff --
    
    This function is equivalent with `val resolvedRelation = 
dataSource.resolveRelation(checkPathExist = false)` in 2.0 
(https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/command/createDataSourceTables.scala#L427).
    



---
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