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

    https://github.com/apache/spark/pull/16626#discussion_r99681470
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
    @@ -814,4 +816,50 @@ object DDLUtils {
           }
         }
       }
    +
    +  /**
    +   * ALTER TABLE ADD COLUMNS command does not support temporary view/table,
    +   * view, or datasource table with text, orc formats or external provider.
    +   */
    +  def verifyAlterTableAddColumn(
    +      catalog: SessionCatalog,
    +      table: TableIdentifier): CatalogTable = {
    +    if (catalog.isTemporaryTable(table)) {
    +      throw new AnalysisException(
    +        s"${table.toString} is a temporary VIEW, which does not support 
ALTER ADD COLUMNS.")
    +    }
    +
    +    val catalogTable = catalog.getTableMetadata(table)
    +    if (catalogTable.tableType == CatalogTableType.VIEW) {
    +      throw new AnalysisException(
    +        s"${table.toString} is a VIEW, which does not support ALTER ADD 
COLUMNS.")
    +    }
    +
    +    if (isDatasourceTable(catalogTable)) {
    +      catalogTable.provider.get match {
    +        case provider if provider.toLowerCase == "text" =>
    +          // TextFileFormat can not support adding column either because 
text datasource table
    +          // is resolved as a single-column table only.
    +          throw new AnalysisException(
    +            s"""${table.toString} is a text format datasource table,
    +               |which does not support ALTER ADD COLUMNS.""".stripMargin)
    +        case provider if provider.toLowerCase == "orc"
    +          || provider.startsWith("org.apache.spark.sql.hive.orc") =>
    --- End diff --
    
    I will double check with this case.. If `orc` is the only representation in 
CatalogTable.provider, I will reduce the logic here. 


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