cloud-fan commented on a change in pull request #26097: [SPARK-29421][SQL]
Supporting Create Table Like Stored as/Using FileFormat
URL: https://github.com/apache/spark/pull/26097#discussion_r334493557
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala
##########
@@ -996,13 +996,30 @@ class SparkSqlAstBuilder(conf: SQLConf) extends
AstBuilder(conf) {
* {{{
* CREATE TABLE [IF NOT EXISTS] [db_name.]table_name
* LIKE [other_db_name.]existing_table_name [locationSpec]
+ * [STORED AS file_format | USING file_format]
* }}}
*/
override def visitCreateTableLike(ctx: CreateTableLikeContext): LogicalPlan
= withOrigin(ctx) {
val targetTable = visitTableIdentifier(ctx.target)
val sourceTable = visitTableIdentifier(ctx.source)
val location = Option(ctx.locationSpec).map(visitLocationSpec)
- CreateTableLikeCommand(targetTable, sourceTable, location, ctx.EXISTS !=
null)
+ val fileStorage = Option(ctx.createFileFormat).map(visitCreateFileFormat)
+ val provider = Option(ctx.tableProvider).map(_.qualifiedName.getText)
+ if (fileStorage.isDefined && provider.isDefined) {
+ throw new ParseException(
+ "STORED AS and USING should not be specified both", ctx)
+ }
+ val fileFormat = if (fileStorage.isDefined) {
+ Some(HiveSerDe(
+ inputFormat = fileStorage.get.inputFormat,
+ outputFormat = fileStorage.get.outputFormat,
+ serde = fileStorage.get.serde))
+ } else if (provider.isDefined) {
+ provider.flatMap(HiveSerDe.sourceToSerDe)
Review comment:
This can only support some Hive-compatible sources.
I think there are 2 features:
1. specify a different table provider in CREATE TABLE LIKE
2. Hive compatibility
Can we focus on feature 1 first which is more important?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]