Skip to content

Commit

Permalink
No need for superfluous always-true filter conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklaskowski committed Jul 26, 2023
1 parent c78daef commit 87a5e02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ trait ClassicMergeExecutor extends MergeIntoMaterializeSource with MergeOutputGe
val matchedPredicate =
if (isMatchedOnly) {
matchedClauses
.map(clause => clause.condition.getOrElse(Literal(true)))
.flatMap(_.condition)
.reduce((a, b) => Or(a, b))
} else Literal(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ trait InsertOnlyMergeExecutor extends MergeOutputGeneration {
val incrSourceRowCountExpr = incrementMetricAndReturnBool(numSourceRowsMetric, true)
// source DataFrame
var sourceDF = getSourceDF().filter(new Column(incrSourceRowCountExpr))
if (notMatchedClauses.size == 1) {
// If there is only one insert clause, then filter out the source rows that do not
// satisfy the clause condition because those rows will not be written out.
sourceDF =
sourceDF.filter(new Column(notMatchedClauses.head.condition.getOrElse(Literal(true))))
// If there is only one insert clause, then filter out the source rows that do not
// satisfy the clause condition because those rows will not be written out.
if (notMatchedClauses.size == 1 && notMatchedClauses.head.condition.isDefined) {
sourceDF = sourceDF.filter(Column(notMatchedClauses.head.condition.get))
}

var dataSkippedFiles: Option[Seq[AddFile]] = None
Expand Down

0 comments on commit 87a5e02

Please sign in to comment.