@@ -178,7 +178,6 @@ func (qr *ProxyQrouter) DeparseKeyWithRangesInternal(ctx context.Context, key st
178
178
179
179
// TODO : unit tests
180
180
func (qr * ProxyQrouter ) RouteKeyWithRanges (ctx context.Context , expr lyx.Node , meta * RoutingMetadataContext , hf hashfunction.HashFunctionType ) (* routingstate.DataShardRoute , error ) {
181
-
182
181
switch e := expr .(type ) {
183
182
case * lyx.ParamRef :
184
183
if e .Number > len (meta .params ) {
@@ -229,85 +228,51 @@ func (qr *ProxyQrouter) routeByClause(ctx context.Context, expr lyx.Node, meta *
229
228
230
229
switch lft := texpr .Left .(type ) {
231
230
case * lyx.ColumnRef :
232
- /* simple key-value pair */
233
- switch rght := texpr .Right .(type ) {
234
- case * lyx.ParamRef :
235
- // ignore
236
- case * lyx.AExprSConst :
237
- alias , colname := lft .TableAlias , lft .ColName
238
231
239
- if ! meta .CheckColumnRls (colname ) {
240
- spqrlog .Zero .Debug ().
241
- Str ("colname" , colname ).
242
- Msg ("skip column due no rule mathing" )
243
- continue
244
- }
232
+ alias , colname := lft .TableAlias , lft .ColName
245
233
246
- resolvedRelation , err := meta .ResolveRelationByAlias (alias )
247
- if err == nil {
248
- // TBD: postpone routing from here to root of parsing tree
249
- meta .RecordConstExpr (resolvedRelation , colname , rght .Value )
250
- } else {
251
- meta .unparsed_columns [colname ] = struct {}{}
252
- }
253
- case * lyx.AExprIConst :
254
- alias , colname := lft .TableAlias , lft .ColName
234
+ if ! meta .CheckColumnRls (colname ) {
235
+ spqrlog .Zero .Debug ().
236
+ Str ("colname" , colname ).
237
+ Msg ("skip column due no rule mathing" )
238
+ continue
239
+ }
255
240
256
- if ! meta .CheckColumnRls ( colname ) {
257
- spqrlog . Zero . Debug ().
258
- Str ( "colname" , colname ).
259
- Msg ( "skip column due no rule mathing" )
260
- continue
261
- }
241
+ resolvedRelation , err := meta .ResolveRelationByAlias ( alias )
242
+ if err != nil {
243
+ // failed to relove relation, skip column
244
+ meta . unparsed_columns [ colname ] = struct {}{}
245
+ continue
246
+ }
262
247
263
- resolvedRelation , err := meta .ResolveRelationByAlias (alias )
264
- if err == nil {
265
- // TBD: postpone routing from here to root of parsing tree
266
- // maybe expimely inefficient. Will be fixed in SPQR-2.0
267
- meta .RecordConstExpr (resolvedRelation , colname , fmt .Sprintf ("%d" , rght .Value ))
268
- } else {
269
- meta .unparsed_columns [colname ] = struct {}{}
248
+ /* simple key-value pair */
249
+ switch rght := texpr .Right .(type ) {
250
+ case * lyx.ParamRef :
251
+ if rght .Number > len (meta .params ) {
252
+ return ComplexQuery
270
253
}
271
254
255
+ // will not work not ints
256
+ meta .RecordConstExpr (resolvedRelation , colname , string (meta .params [rght .Number - 1 ]))
257
+
258
+ case * lyx.AExprSConst :
259
+ // TBD: postpone routing from here to root of parsing tree
260
+ meta .RecordConstExpr (resolvedRelation , colname , rght .Value )
261
+ case * lyx.AExprIConst :
262
+ // TBD: postpone routing from here to root of parsing tree
263
+ // maybe expimely inefficient. Will be fixed in SPQR-2.0
264
+ meta .RecordConstExpr (resolvedRelation , colname , fmt .Sprintf ("%d" , rght .Value ))
272
265
case * lyx.AExprList :
273
266
if len (rght .List ) != 0 {
274
267
expr := rght .List [0 ]
275
268
switch bexpr := expr .(type ) {
276
269
case * lyx.AExprSConst :
277
- alias , colname := lft .TableAlias , lft .ColName
278
-
279
- if ! meta .CheckColumnRls (colname ) {
280
- spqrlog .Zero .Debug ().
281
- Str ("colname" , colname ).
282
- Msg ("skip column due no rule mathing" )
283
- continue
284
- }
285
-
286
- resolvedRelation , err := meta .ResolveRelationByAlias (alias )
287
- if err == nil {
288
- // TBD: postpone routing from here to root of parsing tree
289
- meta .RecordConstExpr (resolvedRelation , colname , bexpr .Value )
290
- } else {
291
- meta .unparsed_columns [colname ] = struct {}{}
292
- }
270
+ // TBD: postpone routing from here to root of parsing tree
271
+ meta .RecordConstExpr (resolvedRelation , colname , bexpr .Value )
293
272
case * lyx.AExprIConst :
294
- alias , colname := lft .TableAlias , lft .ColName
295
-
296
- if ! meta .CheckColumnRls (colname ) {
297
- spqrlog .Zero .Debug ().
298
- Str ("colname" , colname ).
299
- Msg ("skip column due no rule mathing" )
300
- continue
301
- }
302
-
303
- resolvedRelation , err := meta .ResolveRelationByAlias (alias )
304
- if err == nil {
305
- // TBD: postpone routing from here to root of parsing tree
306
- // maybe expimely inefficient. Will be fixed in SPQR-2.0
307
- meta .RecordConstExpr (resolvedRelation , colname , fmt .Sprintf ("%d" , bexpr .Value ))
308
- } else {
309
- meta .unparsed_columns [colname ] = struct {}{}
310
- }
273
+ // TBD: postpone routing from here to root of parsing tree
274
+ // maybe expimely inefficient. Will be fixed in SPQR-2.0
275
+ meta .RecordConstExpr (resolvedRelation , colname , fmt .Sprintf ("%d" , bexpr .Value ))
311
276
}
312
277
}
313
278
0 commit comments