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

    https://github.com/apache/spark/pull/14531#discussion_r76935703
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
    @@ -58,18 +63,32 @@ case class CreateTableLikeCommand(
           throw new AnalysisException(
             s"Source table in CREATE TABLE LIKE does not exist: 
'$sourceTable'")
         }
    -    if (catalog.isTemporaryTable(sourceTable)) {
    -      throw new AnalysisException(
    -        s"Source table in CREATE TABLE LIKE cannot be temporary: 
'$sourceTable'")
    -    }
     
    -    val tableToCreate = catalog.getTableMetadata(sourceTable).copy(
    -      identifier = targetTable,
    -      tableType = CatalogTableType.MANAGED,
    -      createTime = System.currentTimeMillis,
    -      lastAccessTime = -1).withNewStorage(locationUri = None)
    +    val sourceTableDesc = catalog.getTableMetadata(sourceTable)
     
    -    catalog.createTable(tableToCreate, ifNotExists)
    +    val newSerdeProp =
    +      if (DDLUtils.isDatasourceTable(sourceTableDesc)) {
    +        val newPath = catalog.defaultTablePath(targetTable)
    +        sourceTableDesc.storage.properties.filterKeys(_.toLowerCase != 
"path") ++
    +          Map("path" -> newPath)
    +      } else {
    +        sourceTableDesc.storage.properties
    +      }
    +    val newStorage = sourceTableDesc.storage.copy(
    +      locationUri = None,
    +      properties = newSerdeProp)
    +
    +    val newTableDesc =
    +      CatalogTable(
    +        identifier = targetTable,
    +        tableType = CatalogTableType.MANAGED,
    +        storage = newStorage,
    +        schema = sourceTableDesc.schema,
    +        provider = sourceTableDesc.provider,
    --- End diff --
    
    Will fix it tomorrow. I need to recheck whether the new change is 
consistent with the behavior of Hive. Thanks!


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