Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EinKrebs committed Apr 18, 2024
1 parent 9249b67 commit b523916
Show file tree
Hide file tree
Showing 2 changed files with 38 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
23 changes: 23 additions & 0 deletions router/qrouter/proxy_routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,25 @@ 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,
},
} {
parserRes, err := lyx.Parse(tt.query)

Expand Down Expand Up @@ -1348,3 +1367,7 @@ func TestMiscRouting(t *testing.T) {
}
}
}

func TestSimple(t *testing.T) {

}

0 comments on commit b523916

Please sign in to comment.