Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EinKrebs committed Apr 25, 2024
1 parent ce2645c commit 16ec98e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
20 changes: 15 additions & 5 deletions router/qrouter/proxy_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,27 +282,37 @@ func (qr *ProxyQrouter) routeByClause(ctx context.Context, expr lyx.Node, meta *
switch rght := texpr.Right.(type) {
case *lyx.ParamRef:
if rght.Number <= len(meta.params) {
return qr.RecordDistributionKeyColumnValue(meta, alias, colname, string(meta.params[rght.Number-1]))
if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, string(meta.params[rght.Number-1])); err != nil {
return err
}
}
// else error out?
case *lyx.AExprSConst:
// TBD: postpone routing from here to root of parsing tree
return qr.RecordDistributionKeyColumnValue(meta, alias, colname, rght.Value)
if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, rght.Value); err != nil {
return err
}
case *lyx.AExprIConst:
// TBD: postpone routing from here to root of parsing tree
// maybe expimely inefficient. Will be fixed in SPQR-2.0
return qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", rght.Value))
if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", rght.Value)); err != nil {
return err
}
case *lyx.AExprList:
if len(rght.List) != 0 {
expr := rght.List[0]
switch bexpr := expr.(type) {
case *lyx.AExprSConst:
// TBD: postpone routing from here to root of parsing tree
return qr.RecordDistributionKeyColumnValue(meta, alias, colname, bexpr.Value)
if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, bexpr.Value); err != nil {
return err
}
case *lyx.AExprIConst:
// TBD: postpone routing from here to root of parsing tree
// maybe expimely inefficient. Will be fixed in SPQR-2.0
return qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", bexpr.Value))
if err := qr.RecordDistributionKeyColumnValue(meta, alias, colname, fmt.Sprintf("%d", bexpr.Value)); err != nil {
return err
}
}
}
case *lyx.FuncApplication:
Expand Down
22 changes: 22 additions & 0 deletions router/qrouter/proxy_routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,24 @@ func TestSingleShard(t *testing.T) {
err: nil,
},

{
query: "SELECT * FROM t WHERE i = 12 AND j = 1;",
exp: routingstate.ShardMatchState{
Route: &routingstate.DataShardRoute{
Shkey: kr.ShardKey{
Name: "sh2",
},
Matchedkr: &kr.KeyRange{
ShardID: "sh2",
ID: "id2",
Distribution: distribution,
LowerBound: []byte("11"),
},
},
TargetSessionAttrs: "any",
},
err: nil,
},
{
query: "SELECT * FROM t WHERE i = 12 UNION ALL SELECT * FROM xxmixed WHERE i = 22;",
exp: routingstate.ShardMatchState{
Expand Down Expand Up @@ -1395,3 +1413,7 @@ func TestMiscRouting(t *testing.T) {
}
}
}

func TestSimple(t *testing.T) {

}

0 comments on commit 16ec98e

Please sign in to comment.