@@ -3620,6 +3620,42 @@ top-k
36203620 └── projections
36213621 └── vec1:9 <-> '[3,1,2]' [as=column15:15, outer=(9), immutable]
36223622
3623+ # Case with additional projected expressions.
3624+ opt expect=GenerateVectorSearch
3625+ SELECT id, vec1, latitude*longitude, data1*data2 FROM index_tab
3626+ ORDER BY vec1 <-> '[3,1,2]' LIMIT 5;
3627+ ----
3628+ top-k
3629+ ├── columns: id:1!null vec1:9 "?column?":15 "?column?":16!null [hidden: column17:17]
3630+ ├── internal-ordering: +17
3631+ ├── k: 5
3632+ ├── cardinality: [0 - 5]
3633+ ├── immutable
3634+ ├── key: (1)
3635+ ├── fd: (1)-->(9,15-17), (9)-->(17)
3636+ ├── ordering: +17
3637+ └── project
3638+ ├── columns: "?column?":15 "?column?":16!null column17:17 id:1!null vec1:9
3639+ ├── immutable
3640+ ├── key: (1)
3641+ ├── fd: (1)-->(9,15-17), (9)-->(17)
3642+ ├── inner-join (lookup index_tab)
3643+ │ ├── columns: id:1!null latitude:4 longitude:5 data1:6!null data2:7!null vec1:9
3644+ │ ├── key columns: [1] = [1]
3645+ │ ├── lookup columns are key
3646+ │ ├── key: (1)
3647+ │ ├── fd: (1)-->(4-7,9)
3648+ │ ├── vector-search index_tab@index_tab_vec1_idx,vector
3649+ │ │ ├── columns: id:1!null
3650+ │ │ ├── target nearest neighbors: 5
3651+ │ │ ├── key: (1)
3652+ │ │ └── '[3,1,2]'
3653+ │ └── filters (true)
3654+ └── projections
3655+ ├── latitude:4 * longitude:5 [as="?column?":15, outer=(4,5), immutable]
3656+ ├── data1:6 * data2:7 [as="?column?":16, outer=(6,7), immutable]
3657+ └── vec1:9 <-> '[3,1,2]' [as=column17:17, outer=(9), immutable]
3658+
36233659# Case with prefix columns.
36243660opt expect=GenerateVectorSearch
36253661SELECT id, val, vec1 FROM index_tab WHERE data1 = 1 AND data2 = 2 ORDER BY vec1 <-> '[3,1,2]' LIMIT 5;
@@ -3783,8 +3819,7 @@ top-k
37833819 └── projections
37843820 └── vec:5 <-> '[3,1,2]' [as=column9:9, outer=(5), immutable]
37853821
3786- # Currently, the extra projection for col4 prevents the vector search.
3787- opt expect-not=GenerateVectorSearch
3822+ opt expect=GenerateVectorSearch
37883823SELECT * FROM index_with_computed_tab WHERE col3 = 5 ORDER BY vec <-> '[3,1,2]' LIMIT 5;
37893824----
37903825top-k
@@ -3798,20 +3833,20 @@ top-k
37983833 └── project
37993834 ├── columns: column9:9 col4:4!null col1:1!null col2:2!null col3:3!null vec:5
38003835 ├── immutable
3801- ├── fd: ()-->(3), (5)-->(9), (1,2)-->(4 )
3802- ├── select
3836+ ├── fd: (1,2 )-->(3,4 ), (5)-->(9)
3837+ ├── inner-join (lookup index_with_computed_tab)
38033838 │ ├── columns: col1:1!null col2:2!null col3:3!null vec:5
3804- │ ├── fd: ()-->(3)
3805- │ ├── scan index_with_computed_tab
3806- │ │ ├── columns: col1:1!null col2:2!null col3:3!null vec:5
3807- │ │ ├── computed column expressions
3808- │ │ │ ├── col3:3
3809- │ │ │ │ └ ── col1:1 + col2:2
3810- │ │ │ └ ── col4:4
3811- │ │ │ └── col1:1 * col2:2
3812- │ │ └ ── fd : (1,2)-->(3 )
3813- │ └── filters
3814- │ └── col3:3 = 5 [outer=(3), constraints=(/3: [/5 - /5]; tight), fd=()-->(3)]
3839+ │ ├── key columns: [6] = [6]
3840+ │ ├── lookup columns are key
3841+ │ ├── fd: (1,2)-->(3)
3842+ │ ├── vector-search index_with_computed_tab@index_with_computed_tab_col3_vec_idx,vector
3843+ │ │ ├── columns: rowid:6!null
3844+ │ │ ├ ── target nearest neighbors: 5
3845+ │ │ ├ ── prefix constraint: /3
3846+ │ │ │ └── [/5 - /5]
3847+ │ │ ├ ── key : (6 )
3848+ │ │ └── '[3,1,2]'
3849+ │ └── filters (true)
38153850 └── projections
38163851 ├── vec:5 <-> '[3,1,2]' [as=column9:9, outer=(5), immutable]
38173852 └── col1:1 * col2:2 [as=col4:4, outer=(1,2), immutable]
0 commit comments