You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improved Parenthesis Handling and Spanner Limit Mitigation (#1272)
* Improved Parenthesis Handling and Spanner Limit Mitigation
This PR improves search query generation by:
- Grammar: Adding parenthesizedCriteria to explicitly capture parenthesized expressions.
- Visitor: Updating the visitor to create SearchNode objects with parenthesis information.
- Filter Generation: Refactoring traverseAndGenerateFilters to correctly handle parentheses and minimize unnecessary nesting in Spanner queries, mitigating Spanner's complexity limits.
Without this change, a user cannot query more than 50 ids at a given time.
* fix nits, add nested test case, & address feedback
expectedClauses: []string{`((wf.ID NOT IN (SELECT WebFeatureID FROM BrowserFeatureAvailabilities
323
-
WHERE BrowserName = @param0)) AND (fbs.Status = @param1))`},
474
+
expectedClauses: []string{`wf.ID NOT IN (SELECT WebFeatureID FROM BrowserFeatureAvailabilities
475
+
WHERE BrowserName = @param0) AND fbs.Status = @param1`},
324
476
expectedParams: map[string]interface{}{
325
477
"param0": "chrome",
326
478
"param1": "high",
327
479
},
328
480
},
329
481
{
330
482
inputTestTree: complexQuery,
331
-
expectedClauses: []string{`(((wf.ID IN (SELECT WebFeatureID FROM BrowserFeatureAvailabilities
332
-
WHERE BrowserName = @param0)) AND ((fbs.Status = @param1) OR ((wf.Name_Lowercase LIKE @param2 OR wf.FeatureKey_Lowercase LIKE @param2)))) OR ((wf.Name_Lowercase LIKE @param3 OR wf.FeatureKey_Lowercase LIKE @param3)))`},
483
+
expectedClauses: []string{`wf.ID IN (SELECT WebFeatureID FROM BrowserFeatureAvailabilities
484
+
WHERE BrowserName = @param0) AND (fbs.Status = @param1 OR (wf.Name_Lowercase LIKE @param2 OR wf.FeatureKey_Lowercase LIKE @param2)) OR (wf.Name_Lowercase LIKE @param3 OR wf.FeatureKey_Lowercase LIKE @param3)`},
333
485
expectedParams: map[string]interface{}{
334
486
"param0": "chrome",
335
487
"param1": "high",
@@ -340,7 +492,7 @@ WHERE BrowserName = @param0)) AND ((fbs.Status = @param1) OR ((wf.Name_Lowercase
340
492
{
341
493
inputTestTree: baselineDateRange,
342
494
expectedClauses: []string{
343
-
`((LowDate >= @param0) AND (LowDate <= @param1))`,
expectedClauses: []string{`(wf.FeatureKey_Lowercase = @param0) OR (wf.FeatureKey_Lowercase = @param1) OR (wf.FeatureKey_Lowercase = @param2) OR (wf.FeatureKey_Lowercase = @param3)`},
515
+
expectedParams: map[string]interface{}{
516
+
"param0": "html",
517
+
"param1": "css",
518
+
"param2": "typescript",
519
+
"param3": "javascript",
520
+
},
521
+
},
522
+
{
523
+
inputTestTree: complexNestedQuery,
524
+
expectedClauses: []string{`(wf.ID IN (SELECT WebFeatureID FROM BrowserFeatureAvailabilities
525
+
WHERE BrowserName = @param0) AND (fbs.Status = @param1 OR fbs.Status = @param2)) OR (wf.Name_Lowercase LIKE @param3 OR wf.FeatureKey_Lowercase LIKE @param3)`,
0 commit comments