You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/10/14 21:57:43 UTC

[GitHub] [calcite] hsyuan commented on a change in pull request #1500: [CALCITE-3405] Prune columns for ProjectableFilterableTable when Proj…

hsyuan commented on a change in pull request #1500: [CALCITE-3405] Prune columns for ProjectableFilterableTable when Proj…
URL: https://github.com/apache/calcite/pull/1500#discussion_r334678010
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rel/rules/ProjectTableScanRule.java
 ##########
 @@ -103,30 +106,47 @@ protected static boolean test(TableScan scan) {
   protected void apply(RelOptRuleCall call, Project project, TableScan scan) {
     final RelOptTable table = scan.getTable();
     assert table.unwrap(ProjectableFilterableTable.class) != null;
-    if (!project.isMapping()) {
-      return;
-    }
-    final Mappings.TargetMapping mapping = Project.getPartialMapping(
-            project.getInput().getRowType().getFieldCount(),
-            project.getProjects());
 
-    final ImmutableIntList projects;
-    final ImmutableList<RexNode> filters;
+    final List<Integer> selectedColumns = new ArrayList<>();
+    project.getProjects().forEach(proj -> {
+      proj.accept(new RexVisitorImpl<Void>(true) {
+        public Void visitInputRef(RexInputRef inputRef) {
+          if (!selectedColumns.contains(inputRef.getIndex())) {
+            selectedColumns.add(inputRef.getIndex());
+          }
+          return null;
+        }
+      });
+    });
 
 Review comment:
   Can we use InputFinder here? And it is better to use bit set instead of int list.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services