alex-plekhanov commented on code in PR #13011:
URL: https://github.com/apache/ignite/pull/13011#discussion_r3080488411


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/AbstractPlannerTest.java:
##########
@@ -619,6 +626,49 @@ protected <T extends RelNode> Predicate<RelNode> 
input(Predicate<T> predicate) {
         return input(0, predicate);
     }
 
+    /** Low level conditions analyzer. */
+    private static boolean validateIdxConditions(IgniteIndexScan node, SqlKind 
opKind, String... strConditions) {
+        /** */
+        Set<String> conditions = new HashSet<>();
+
+        /** */
+        RexShuttle shuttle = new RexShuttle() {
+            boolean firstCall = true;
+
+            @Override public RexNode visitCall(RexCall call) {
+                if (firstCall) {

Review Comment:
   If we check only first call, why do we need RexShuttle at all?
   It can be implemented much simplier by checking only root operator and 
operands.
   But It still will be too specialized and seems that can be used only by one 
test.
   Instead I propose to implement something like condition normalizator (I 
think it will be useful in future for other tests), it can be implemented for 
example this way:
   ```
       private static RexNode normalizeCondition(RexBuilder rexBuilder, RexNode 
condition) {
           return new RexShuttle() {
               @Override public RexNode visitCall(RexCall call) {
                   Pair<SqlOperator, List<RexNode>> normalized = 
RexNormalize.normalize(call.getOperator(), call.getOperands());
   
                   return rexBuilder.makeCall(normalized.getKey(), 
normalized.getValue());
               }
           }.apply(condition);
       }
   ``` 
   And to check condition we can do something like:
   ```
       protected <T extends RelNode> Predicate<ProjectableFilterableTableScan> 
satisfyCondition(String condition) {
           return node -> {
               String normCond = 
normalizeCondition(node.getCluster().getRexBuilder(), 
node.condition()).toString();
   
               if (!condition.equals(normCond)) {
                   lastErrorMsg = "Unexpected condition [expected=" + condition 
+ ", actual=" + normCond + ']';
   
                   return false;
               }
   
               return true;
           };
       }
   ```
   In this case we can check normalized condition like:
   ```
   .and(satisfyCondition("AND(=($t0, 0), =($t1, 0), SEARCH($t2, Sarg[0, 1, 
2]))")));
   ``` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to