Skip to content

Commit

Permalink
change the warning for purge
Browse files Browse the repository at this point in the history
Change-Id: I11a9dc214102854f533330a739d32a41500d9278
  • Loading branch information
jackylee-ch committed Aug 5, 2020
1 parent 61cae52 commit b1fc84b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,14 @@ class ResolveCatalogs(val catalogManager: CatalogManager)

case c @ AlterTableDropPartitionStatement(
NonSessionCatalogAndTable(catalog, tableName), _, _, _, _) =>
if (c.purge) {
logWarning("PURGE won't take effect here, please put it in table properties")
}
val table = catalog.asTableCatalog.loadTable(tableName.asIdentifier).asPartitionable
AlterTableDropPartition(
table,
c.specs.map(_.asPartitionIdentifier(table.partitionSchema())),
c.ifExists,
c.purge,
c.retainData)
c.ifExists)
}

object NonSessionCatalogAndTable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,10 @@ case class AlterTableAddPartition(
*
* The syntax of this command is:
* {{{
* ALTER TABLE table DROP [IF EXISTS] PARTITION spec1[, PARTITION spec2, ...] [PURGE];
* ALTER TABLE table DROP [IF EXISTS] PARTITION spec1[, PARTITION spec2, ...];
* }}}
*/
case class AlterTableDropPartition(
table: SupportsPartitions,
partIdents: Seq[InternalRow],
ignoreIfNotExists: Boolean,
purge: Boolean,
retainData: Boolean) extends Command
ignoreIfNotExists: Boolean) extends Command
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ import org.apache.spark.sql.connector.catalog.SupportsPartitions
case class AlterTableDropPartitionExec(
table: SupportsPartitions,
partIdents: Seq[InternalRow],
ignoreIfNotExists: Boolean,
purge: Boolean,
retainData: Boolean) extends V2CommandExec {
ignoreIfNotExists: Boolean) extends V2CommandExec {

override def output: Seq[Attribute] = Seq.empty

override protected def run(): Seq[InternalRow] = {
logWarning("PURGE won't take effect, please put it in table properties")

partIdents.foreach { partIdent =>
if (!table.dropPartition(partIdent) && !ignoreIfNotExists) {
throw new NoSuchPartitionException(table.name(), partIdent, table.partitionSchema())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat
case AlterTableAddPartition(table, parts, ignoreIfExists) =>
AlterTableAddPartitionExec(table, parts, ignoreIfExists) :: Nil

case AlterTableDropPartition(table, partIdents, ignoreIfNotExists, purge, retainData) =>
case AlterTableDropPartition(table, partIdents, ignoreIfNotExists) =>
AlterTableDropPartitionExec(
table, partIdents, ignoreIfNotExists, purge, retainData) :: Nil
table, partIdents, ignoreIfNotExists) :: Nil

case _ => Nil
}
Expand Down

0 comments on commit b1fc84b

Please sign in to comment.