LantaoJin commented on a change in pull request #26097: [SPARK-29421][SQL] Supporting Create Table Like Using Provider URL: https://github.com/apache/spark/pull/26097#discussion_r341139679
########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ########## @@ -57,23 +56,33 @@ import org.apache.spark.sql.util.SchemaUtils * The CatalogTable attributes copied from the source table are storage(inputFormat, outputFormat, * serde, compressed, properties), schema, provider, partitionColumnNames, bucketSpec. * + * Use "CREATE TABLE t1 LIKE t2 USING file_format" + * to specify new file format for t1 from a data source table t2. + * * The syntax of using this command in SQL is: * {{{ * CREATE TABLE [IF NOT EXISTS] [db_name.]table_name - * LIKE [other_db_name.]existing_table_name [locationSpec] + * LIKE [other_db_name.]existing_table_name [locationSpec] [USING provider] * }}} */ case class CreateTableLikeCommand( targetTable: TableIdentifier, sourceTable: TableIdentifier, location: Option[String], - ifNotExists: Boolean) extends RunnableCommand { + ifNotExists: Boolean, + provider: Option[String]) extends RunnableCommand { override def run(sparkSession: SparkSession): Seq[Row] = { val catalog = sparkSession.sessionState.catalog val sourceTableDesc = catalog.getTempViewOrPermanentTableMetadata(sourceTable) - val newProvider = if (sourceTableDesc.tableType == CatalogTableType.VIEW) { + val newProvider = if (provider.isDefined) { + val providerWithLowerCase = provider.get.toLowerCase(Locale.ROOT) + // check the validation of provider input, invalid provider will throw + // AnalysisException or ClassNotFoundException or NoSuchMethodException + DataSource.lookupDataSourceV2(providerWithLowerCase, sparkSession.sessionState.conf) Review comment: Oh, I misunderstand it. It will return None if no V2 implementation. I will fix it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org