Skip to content

Commit

Permalink
add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouxxyy committed Jun 3, 2024
1 parent 4bc277a commit 2402a0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import scala.collection.JavaConverters._
* For those delete conditions with subqueries that only contain partition columns, we can eval them
* in advance. So that when running [[DeleteFromPaimonTableCommand]], we can directly call
* dropPartitions to achieve fast deletion.
*
* Note: this rule must be placed before [[MergePaimonScalarSubqueriers]], because
* [[MergePaimonScalarSubqueriers]] will merge subqueries.
*/
object EvalSubqueriesForDeleteTable extends Rule[LogicalPlan] with ExpressionHelper with Logging {

Expand Down Expand Up @@ -77,7 +80,7 @@ object EvalSubqueriesForDeleteTable extends Rule[LogicalPlan] with ExpressionHel
evalPhysicalSubquery(physicalSubquery)

physicalSubquery.values() match {
case Some(l) if l.nonEmpty => In(expr, l.map(Literal(_, expr.dataType)))
case Some(l) if l.length > 0 => In(expr, l.map(Literal(_, expr.dataType)))
case _ => Literal(false, BooleanType)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ abstract class PaimonOptimizationTestBase extends PaimonSparkTestBase {
checkAnswer(
spark.sql("SELECT * FROM t1 ORDER BY id"),
Row(1, "a", 1) :: Row(5, "e", 4) :: Nil)

// subquery eval nothing
spark.sql(s"""DELETE FROM t1 WHERE
|pt >= (SELECT min(id) FROM t2 WHERE n > 10)""".stripMargin)

checkAnswer(
spark.sql("SELECT * FROM t1 ORDER BY id"),
Row(1, "a", 1) :: Row(5, "e", 4) :: Nil)
}
})
}
Expand Down Expand Up @@ -182,6 +190,14 @@ abstract class PaimonOptimizationTestBase extends PaimonSparkTestBase {
checkAnswer(
spark.sql("SELECT * FROM t1 ORDER BY id"),
Row(1, "a", 1) :: Row(5, "e", 4) :: Nil)

// subquery eval nothing
spark.sql(s"""DELETE FROM t1 WHERE
|pt in (SELECT id FROM t2 WHERE n > 10)""".stripMargin)

checkAnswer(
spark.sql("SELECT * FROM t1 ORDER BY id"),
Row(1, "a", 1) :: Row(5, "e", 4) :: Nil)
}
})
}
Expand Down

0 comments on commit 2402a0a

Please sign in to comment.