Skip to content

Commit 6e5198b

Browse files
authored
[test](regression) Add debug point ANN index-only scan test (apache#63859)
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: The previous ANN index-only scan regression coverage inferred whether source vector columns were skipped by comparing ScanBytes from query profiles. That made the test hard to review and could miss cases where both query shapes still read the source column. Replace that coverage with a dedicated debug-point regression that directly fails if the embedding column is read in index-only scenarios, including a remapped reader-schema case where the source slot index differs from the storage column id. Remove the old profile-based suites and generated output. ### Release note None ### Check List (For Author) - Test: Manual test - git diff --cached --check - Regression test not run per request; an earlier attempt was blocked by Maven writing to /Users/roanhe/.m2/repository under the sandbox - Behavior changed: No - Does this need documentation: No ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
1 parent 1b44c05 commit 6e5198b

7 files changed

Lines changed: 502 additions & 905 deletions

regression-test/data/ann_index_p0/ann_index_only_scan.out

Lines changed: 0 additions & 19 deletions
This file was deleted.

regression-test/suites/ann_index_p0/ann_index_only_scan.groovy

Lines changed: 0 additions & 450 deletions
This file was deleted.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("ann_index_only_scan_compound_debug_point", "nonConcurrent") {
19+
sql "unset variable all;"
20+
sql "set enable_common_expr_pushdown=true;"
21+
sql "set experimental_enable_virtual_slot_for_cse=true;"
22+
sql "set enable_no_need_read_data_opt=true;"
23+
sql "set parallel_pipeline_task_num=1;"
24+
sql "set enable_sql_cache=false;"
25+
sql "set enable_condition_cache=false;"
26+
27+
sql "drop table if exists ann_index_only_scan_compound_debug_point"
28+
sql """
29+
create table ann_index_only_scan_compound_debug_point (
30+
id int not null,
31+
embedding array<float> not null,
32+
comment string not null,
33+
value int null,
34+
index idx_comment(`comment`) using inverted properties("parser" = "english"),
35+
index ann_embedding(`embedding`) using ann properties(
36+
"index_type"="hnsw",
37+
"metric_type"="l2_distance",
38+
"dim"="8"
39+
)
40+
) duplicate key(id)
41+
distributed by hash(id) buckets 1
42+
properties("replication_num"="1");
43+
"""
44+
45+
sql """
46+
insert into ann_index_only_scan_compound_debug_point values
47+
(0, [39.906116, 10.495334, 54.08394, 88.67262, 55.243687, 10.162686, 36.335983, 38.684258], 'alpha people', 100),
48+
(1, [62.759315, 97.15586, 25.832521, 39.604908, 88.76715, 72.64085, 9.688437, 17.721428], 'beta people', 101),
49+
(2, [15.447449, 59.7771, 65.54516, 12.973712, 99.685135, 72.080734, 85.71118, 99.35976], 'gamma', 102),
50+
(3, [72.26747, 46.42257, 32.368374, 80.50209, 5.777631, 98.803314, 7.0915947, 68.62693], 'delta', 103),
51+
(4, [22.098177, 74.10027, 63.634556, 4.710955, 12.405106, 79.39356, 63.014366, 68.67834], 'epsilon', 104),
52+
(5, [27.53003, 72.1106, 50.891026, 38.459953, 68.30715, 20.610682, 94.806274, 45.181377], 'zeta people', 105),
53+
(6, [77.73215, 64.42907, 71.50025, 43.85641, 94.42648, 50.04773, 65.12575, 68.58207], 'eta', 106),
54+
(7, [2.1537063, 82.667885, 16.171143, 71.126656, 5.335274, 40.286068, 11.943586, 3.69409], 'theta', 107),
55+
(8, [54.435013, 56.800594, 59.335514, 55.829235, 85.46627, 33.388138, 11.076194, 20.480877], 'iota', 108),
56+
(9, [76.197945, 60.623528, 84.229805, 31.652937, 71.82595, 48.04684, 71.29212, 30.282396], 'kappa', 109);
57+
"""
58+
59+
def v = "[26.360261917114258,7.05784273147583,32.361351013183594,86.39714050292969,58.79527282714844,27.189321517944336,99.38946533203125,80.19270324707031]"
60+
61+
try {
62+
GetDebugPoint().enableDebugPointForAllBEs(
63+
"segment_iterator._read_columns_by_index", [column_name: "embedding"])
64+
65+
sql """
66+
select id
67+
from ann_index_only_scan_compound_debug_point
68+
where l2_distance_approximate(embedding, ${v}) < 200.0
69+
order by l2_distance_approximate(embedding, ${v})
70+
limit 5;
71+
"""
72+
73+
sql """
74+
select id, l2_distance_approximate(embedding, ${v}) as dist
75+
from ann_index_only_scan_compound_debug_point
76+
where l2_distance_approximate(embedding, ${v}) < 200.0
77+
order by dist
78+
limit 5;
79+
"""
80+
81+
sql """
82+
select id
83+
from ann_index_only_scan_compound_debug_point
84+
where comment match_any 'people'
85+
order by l2_distance_approximate(embedding, ${v})
86+
limit 5;
87+
"""
88+
89+
sql """
90+
select id
91+
from ann_index_only_scan_compound_debug_point
92+
where comment match_any 'people'
93+
and l2_distance_approximate(embedding, ${v}) < 200.0
94+
order by l2_distance_approximate(embedding, ${v})
95+
limit 5;
96+
"""
97+
98+
test {
99+
sql """
100+
select id
101+
from ann_index_only_scan_compound_debug_point
102+
where abs(l2_distance_approximate(embedding, ${v}) + 10) > 10
103+
and l2_distance_approximate(embedding, ${v}) <= 150
104+
order by l2_distance_approximate(embedding, ${v})
105+
limit 5;
106+
"""
107+
exception "does not need to read data"
108+
}
109+
} finally {
110+
GetDebugPoint().disableDebugPointForAllBEs("segment_iterator._read_columns_by_index")
111+
}
112+
113+
try {
114+
GetDebugPoint().enableDebugPointForAllBEs(
115+
"segment_iterator._read_columns_by_index", [column_name: "comment"])
116+
117+
sql """
118+
select id
119+
from ann_index_only_scan_compound_debug_point
120+
where comment match_any 'people'
121+
order by l2_distance_approximate(embedding, ${v})
122+
limit 5;
123+
"""
124+
125+
sql """
126+
select id
127+
from ann_index_only_scan_compound_debug_point
128+
where comment match_any 'people'
129+
and l2_distance_approximate(embedding, ${v}) < 200.0
130+
order by l2_distance_approximate(embedding, ${v})
131+
limit 5;
132+
"""
133+
134+
test {
135+
sql """
136+
select id, comment
137+
from ann_index_only_scan_compound_debug_point
138+
where comment match_any 'people'
139+
order by l2_distance_approximate(embedding, ${v})
140+
limit 5;
141+
"""
142+
exception "does not need to read data"
143+
}
144+
145+
test {
146+
sql """
147+
select id, comment
148+
from ann_index_only_scan_compound_debug_point
149+
where comment match_any 'people'
150+
and l2_distance_approximate(embedding, ${v}) < 200.0
151+
order by l2_distance_approximate(embedding, ${v})
152+
limit 5;
153+
"""
154+
exception "does not need to read data"
155+
}
156+
} finally {
157+
GetDebugPoint().disableDebugPointForAllBEs("segment_iterator._read_columns_by_index")
158+
}
159+
}

0 commit comments

Comments
 (0)