dan-s1 commented on code in PR #10269:
URL: https://github.com/apache/nifi/pull/10269#discussion_r2322486098


##########
nifi-commons/nifi-calcite-utils/src/main/java/org/apache/nifi/sql/internal/NiFiTableScan.java:
##########
@@ -51,6 +51,15 @@ protected NiFiTableScan(final RelOptCluster cluster, final 
RelOptTable table, fi
         super(cluster, cluster.traitSetOf(EnumerableConvention.INSTANCE), 
Collections.emptyList(), table);
         this.fields = fields;
         fieldExpression = Expressions.constant(fields);
+        // Ensure projection pushdown rule is registered with the planner, as 
some Calcite versions
+        // may not invoke the RelNode#register() method.
+        try {
+            cluster.getPlanner().addRule(new 
NiFiProjectTableScanRule(NiFiProjectTableScanRule.Config.DEFAULT));
+        } catch (Exception e) {
+            // Rule may already be registered; intentionally ignored to avoid 
duplicate registration errors.
+            // Touch the exception to avoid PMD EmptyCatchBlock warnings
+            e.getClass();
+        }

Review Comment:
   Naming the exception variable `ignored` informs PMD to leave this alone. See 
PMD 
[EmptyCatchBlock](https://pmd.github.io/pmd/pmd_rules_java_errorprone.html#emptycatchblock)
 documentation for more details
   ```suggestion
           } catch (Exception ignored) {
               // Rule may already be registered; intentionally ignored to 
avoid duplicate registration errors.
           }
   ```



-- 
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