Skip to content

Commit 501aa25

Browse files
committed
[fix](regression) Account for Lance runtime scan choices
### What problem does this PR solve? Problem Summary: The array-predicate suite required every segment-grouped query to search its index. The runtime selector can deliberately scan a tiny BTree read domain at lower estimated cost, so correct rows were followed by an expected-one/actual-zero search assertion failure. Validate requested segments against index searches plus explicit automatic full scans. Preserve exact candidate counts for index searches, require zero candidates for cost-selected scans, and reject unrelated segment fallbacks. Label-only predicates must still search LabelList. ### Release note None. Regression assertion changes only. ### Check List (For Author) - Test: actual suite assertion block passed six valid profile paths and rejected five invalid profiles; the old assertion reproduced the failure. Native runtime-selection C API test, full-suite Groovy 4.0.19 parsing, whitespace and clang-format 16 checks passed. Full external execution remains for CI. - Behavior changed: No product behavior changes. - Does this need documentation: No.
1 parent f1d1441 commit 501aa25

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

‎regression-test/suites/external_table_p0/lance/test_lance_array_predicate_pushdown.groovy‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,34 @@ suite("test_lance_array_predicate_pushdown", "p0,external") {
8686
}
8787
}
8888
assertEquals(c[1], sql(query).collect { (it[0] as Number).intValue() })
89-
// A pushed predicate is not necessarily indexed: also verify runtime searches
90-
// and candidate counts, so a non-indexed fallback cannot satisfy this test.
9189
if (table != "unindexed") {
9290
String profile = profiles.getProfileBySql(token,
93-
["LanceScalarIndexSegmentsSearched", "LanceScalarIndexCandidateRows",
94-
"LanceScalarIndexSegmentFallbacks"])
91+
["LanceScalarIndexSegmentsRequested", "LanceScalarIndexSegmentsSearched",
92+
"LanceScalarIndexCandidateRows", "LanceScalarIndexSegmentFallbacks",
93+
"LanceScalarIndexAutoFullScans"])
9594
def counter = { String name ->
9695
def matches = profile =~ /${name}: (?:sum )?(\d+)\b/
9796
assertTrue(matches.find(), "Missing counter ${name}: ${profile}")
9897
return matches.group(1).toLong()
9998
}
100-
// Broad complements stay as parallel scans without repeated segment searches.
101-
long expectedSearches = c[2] == -1 ? 0L : 1L
102-
assertEquals(expectedSearches, counter("LanceScalarIndexSegmentsSearched"))
103-
long expectedCandidates = c[2] == null ? -1L :
99+
// The cost selector may scan a small indexed domain instead of searching.
100+
// Account for that decision without accepting unrelated index fallbacks.
101+
long expectedRequests = c[2] == -1 ? 0L : 1L
102+
long runtimeFullScans = counter("LanceScalarIndexAutoFullScans")
103+
// Only category has a cost-ranked BTree; label-only predicates
104+
// must continue to exercise their LabelList index.
105+
if (!c[0].contains("category")) {
106+
assertEquals(0L, runtimeFullScans)
107+
}
108+
assertEquals(expectedRequests, counter("LanceScalarIndexSegmentsRequested"))
109+
assertEquals(expectedRequests,
110+
counter("LanceScalarIndexSegmentsSearched") + runtimeFullScans)
111+
long expectedCandidates = runtimeFullScans > 0 ? 0L : c[2] == null ? -1L :
104112
(c[table == "partial" ? 3 : 2] as Number).longValue()
105113
if (expectedCandidates >= 0) {
106114
assertEquals(expectedCandidates, counter("LanceScalarIndexCandidateRows"))
107115
}
108-
assertEquals(0L, counter("LanceScalarIndexSegmentFallbacks"))
116+
assertEquals(runtimeFullScans, counter("LanceScalarIndexSegmentFallbacks"))
109117
}
110118
}
111119
// NULL needle matching and ordered subsequence matching have Doris-specific semantics.

0 commit comments

Comments
 (0)