Skip to content

Commit

Permalink
fix regression - should be able to plan subquery on top of subquery
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed Mar 16, 2021
1 parent 366fb98 commit 1aae1b6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go/vt/vtgate/planbuilder/filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func planFilter(pb *primitiveBuilder, input logicalPlan, filter sqlparser.Expr,
}
node.UpdatePlan(pb, filter)
return node, nil
case *pulloutSubquery:
return planFilter(pb, node.underlying, filter, whereType, origin)
case *vindexFunc:
return filterVindexFunc(node, filter)
case *subquery:
Expand Down
43 changes: 43 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/filter_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1773,3 +1773,46 @@
"SysTableTableSchema": "VARBINARY(\"ks\")"
}
}

# pullout sq after pullout sq
"select id from user where not id in (select user_extra.col from user_extra where user_extra.user_id = 42) and id in (select user_extra.col from user_extra where user_extra.user_id = 411)"
{
"QueryType": "SELECT",
"Original": "select id from user where not id in (select user_extra.col from user_extra where user_extra.user_id = 42) and id in (select user_extra.col from user_extra where user_extra.user_id = 411)",
"Instructions": {
"OperatorType": "Subquery",
"Variant": "PulloutIn",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "SelectEqualUnique",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select user_extra.col from user_extra where 1 != 1",
"Query": "select user_extra.col from user_extra where user_extra.user_id = 42",
"Table": "user_extra",
"Values": [
42
],
"Vindex": "user_index"
},
{
"OperatorType": "Route",
"Variant": "SelectIN",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"FieldQuery": "select id from user where 1 != 1",
"Query": "select id from user where :__sq_has_values1 = 1 and id in ::__vals and not (:__sq_has_values2 = 1 and id in ::__sq2)",
"Table": "user",
"Values": [
"::__sq1"
],
"Vindex": "user_index"
}
]
}
}

0 comments on commit 1aae1b6

Please sign in to comment.