Skip to content

Commit

Permalink
[CARMEL-2663] Supporting insert overwrite with static/dynamic partiti…
Browse files Browse the repository at this point in the history
…ons (delta-io#41)
  • Loading branch information
LantaoJin authored and GitHub Enterprise committed Apr 27, 2020
1 parent 8871c00 commit 815e98e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main/scala/org/apache/spark/sql/delta/DeltaLog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,25 @@ class DeltaLog private(
overwrite: Boolean,
metrics: Map[String, SQLMetric]): Unit = {
val mode = if (overwrite) SaveMode.Overwrite else SaveMode.Append
val deltaOptions = data.queryExecution.logical match {
case InsertIntoDataSource(
LogicalRelation(_: HadoopFsRelation with InsertableRelation, _, Some(_), _),
_, _, staticPartitions, _, _) =>
val predicates = staticPartitions.map {
case (key, value) => key + "=" + value
}.mkString(" AND ")
if (predicates.isEmpty) {
Map.empty[String, String]
} else {
Map(DeltaOptions.REPLACE_WHERE_OPTION -> predicates)
}
case _ =>
Map.empty[String, String]
}
WriteIntoDelta(
deltaLog = DeltaLog.this,
mode = mode,
new DeltaOptions(Map.empty[String, String], spark.sessionState.conf),
new DeltaOptions(deltaOptions, spark.sessionState.conf),
partitionColumns = partitionSchema.map(_.name),
configuration = Map.empty,
data = data,
Expand Down

0 comments on commit 815e98e

Please sign in to comment.