Github user krisgeus commented on a diff in the pull request: https://github.com/apache/spark/pull/21893#discussion_r205988632 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala --- @@ -857,6 +857,32 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder(conf) { Option(ctx.partitionSpec).map(visitNonOptionalPartitionSpec)) } + /** + * Create an [[AlterTableFormatPropertiesCommand]] command. + * + * For example: + * {{{ + * ALTER TABLE table [PARTITION spec] SET FILEFORMAT format; + * }}} + */ + override def visitSetTableFormat(ctx: SetTableFormatContext): LogicalPlan = withOrigin(ctx) { + val format = (ctx.fileFormat) match { + // Expected format: INPUTFORMAT input_format OUTPUTFORMAT output_format + case (c: TableFileFormatContext) => + visitTableFileFormat(c) + // Expected format: SEQUENCEFILE | TEXTFILE | RCFILE | ORC | PARQUET | AVRO + case (c: GenericFileFormatContext) => + visitGenericFileFormat(c) + case _ => + throw new ParseException("Expected STORED AS ", ctx) + } + AlterTableFormatCommand( + visitTableIdentifier(ctx.tableIdentifier), + format, + // TODO a partition spec is allowed to have optional values. This is currently violated. + Option(ctx.partitionSpec).map(visitNonOptionalPartitionSpec)) --- End diff -- Todo was copied from other command. Removed it because indeed it didn;t clarify anything. And yes if partitionspec is left out of the command, the format of the table is changed according to the hive language manual
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org