Skip to content

Commit 3b2cf89

Browse files
committed
Add Literal field to the OrderAndLimit struct used for tracking expressions that use vector indexes.
1 parent 6e94253 commit 3b2cf89

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

sql/analyzer/replace_order_by_distance.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,16 @@ func replaceIdxOrderByDistanceHelper(ctx *sql.Context, scope *plan.Scope, node s
6060
return n, transform.SameTree, nil
6161
}
6262
var column sql.Expression
63+
var literal sql.Expression
6364
_, leftIsLiteral := distance.LeftChild.(*expression.Literal)
6465
if leftIsLiteral {
6566
column = distance.RightChild
67+
literal = distance.LeftChild
6668
} else {
6769
_, rightIsLiteral := distance.RightChild.(*expression.Literal)
6870
if rightIsLiteral {
6971
column = distance.LeftChild
72+
literal = distance.RightChild
7073
} else {
7174
return n, transform.SameTree, nil
7275
}
@@ -99,6 +102,7 @@ func replaceIdxOrderByDistanceHelper(ctx *sql.Context, scope *plan.Scope, node s
99102
VectorOrderAndLimit: sql.OrderAndLimit{
100103
OrderBy: distance,
101104
Limit: limit,
105+
Literal: literal,
102106
},
103107
}
104108
nn, err := plan.NewStaticIndexedAccessForTableNode(n, lookup)

sql/core.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ func IncrementStatusVariable(ctx *Context, name string, val int) {
894894
type OrderAndLimit struct {
895895
OrderBy Expression
896896
Limit Expression
897+
Literal Expression
897898
CalcFoundRows bool
898899
}
899900

0 commit comments

Comments
 (0)