Skip to content

Commit

Permalink
Add more UT
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen committed Jul 8, 2024
1 parent f58d10e commit 84737da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ApplyFlintSparkCoveringIndex(flint: FlintSpark)
} else {
// Iterate each sub plan tree in the given plan
plan transform {
case filter @ Filter(condition, Relation(sourceRelation)) if isConjunction(condition) =>
case filter @ Filter(condition, Relation(sourceRelation)) =>
doApply(plan, sourceRelation, Some(condition))
.map(newRelation => filter.copy(child = newRelation))
.getOrElse(filter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ class ApplyFlintSparkCoveringIndexSuite extends FlintSuite with Matchers {
}
}

test("should not apply if covering index with disjunction filtering condition") {
assertFlintQueryRewriter
.withQuery(s"SELECT name FROM $testTable WHERE name = 'A' AND age > 30")
.withIndex(
new FlintSparkCoveringIndex(
indexName = "partial",
tableName = testTable,
indexedColumns = Map("name" -> "string", "age" -> "int"),
filterCondition = Some("name = 'A' OR age > 30")))
.assertIndexNotUsed(testTable)
}

test("should not apply if covering index is logically deleted") {
assertFlintQueryRewriter
.withQuery(s"SELECT name FROM $testTable")
Expand Down Expand Up @@ -156,6 +168,8 @@ class ApplyFlintSparkCoveringIndexSuite extends FlintSuite with Matchers {
s"SELECT name, age FROM $testTable",
s"SELECT age, name FROM $testTable",
s"SELECT name FROM $testTable WHERE age = 30",
s"SELECT name FROM $testTable WHERE name = 'A' AND age = 30",
s"SELECT name FROM $testTable WHERE name = 'A' OR age = 30",
s"SELECT SUBSTR(name, 1) FROM $testTable WHERE ABS(age) = 30",
s"SELECT COUNT(*) FROM $testTable GROUP BY age",
s"SELECT name, COUNT(*) FROM $testTable WHERE age > 30 GROUP BY name",
Expand Down

0 comments on commit 84737da

Please sign in to comment.