Skip to content

Commit c7431b0

Browse files
committed
fix trigger test ('new' table was not found in vertex finding scope when filter was pushed down to join)
1 parent b4981db commit c7431b0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sql/memo/join_order_builder.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,15 @@ func (j *joinOrderBuilder) hasEqEdge(leftCol, rightCol sql.ColumnId) bool {
395395
return false
396396
}
397397

398-
func (j *joinOrderBuilder) findVertexFromCol(col sql.ColumnId) (vertexIndex, GroupId) {
398+
func (j *joinOrderBuilder) findVertexFromCol(col sql.ColumnId) (vertexIndex, GroupId, bool) {
399399
for i, v := range j.vertices {
400400
if t, ok := v.(SourceRel); ok {
401401
if t.Group().RelProps.FuncDeps().All().Contains(col) {
402-
return vertexIndex(i), t.Group().Id
402+
return vertexIndex(i), t.Group().Id, true
403403
}
404404
}
405405
}
406-
panic("vertex not found")
406+
return 0, 0, false
407407
}
408408

409409
func (j *joinOrderBuilder) findVertexFromGroup(grp GroupId) vertexIndex {
@@ -421,8 +421,11 @@ func (j *joinOrderBuilder) findVertexFromGroup(grp GroupId) vertexIndex {
421421
// on an equality filter between two columns.
422422
func (j *joinOrderBuilder) makeTransitiveEdge(col1, col2 sql.ColumnId) {
423423
var vert vertexSet
424-
v1, _ := j.findVertexFromCol(col1)
425-
v2, _ := j.findVertexFromCol(col2)
424+
v1, _, v1found := j.findVertexFromCol(col1)
425+
v2, _, v2found := j.findVertexFromCol(col2)
426+
if !v1found || !v2found {
427+
return
428+
}
426429
vert = vert.add(v1).add(v2)
427430

428431
// find edge where the vertices are provided but partitioned

0 commit comments

Comments
 (0)