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 2020/01/10 08:36:13 UTC

[GitHub] [calcite] danny0405 commented on a change in pull request #1702: Patch queue: refine optimizer estimations, refine rules, normalize RexNodes, ...

danny0405 commented on a change in pull request #1702: Patch queue: refine optimizer estimations, refine rules, normalize RexNodes, ...
URL: https://github.com/apache/calcite/pull/1702#discussion_r365120817
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
 ##########
 @@ -84,15 +90,59 @@ public static EnumerableTableScan create(RelOptCluster cluster,
   }
 
   /** Returns whether EnumerableTableScan can generate code to handle a
-   * particular variant of the Table SPI. */
+   * particular variant of the Table SPI.
+   * @deprecated
+   **/
+  @Deprecated
   public static boolean canHandle(Table table) {
-    // FilterableTable and ProjectableFilterableTable cannot be handled in
-    // enumerable convention because they might reject filters and those filters
-    // would need to be handled dynamically.
+    if (table instanceof TransientTable) {
+      // CALCITE-3673: TransientTable can't be implemented with Enumerable
+      return false;
+    }
+    // See org.apache.calcite.prepare.RelOptTableImpl.getClassExpressionFunction
     return table instanceof QueryableTable
+        || table instanceof FilterableTable
+        || table instanceof ProjectableFilterableTable
         || table instanceof ScannableTable;
   }
 
+  /** Returns whether EnumerableTableScan can generate code to handle a
+   * particular variant of the Table SPI.
+   **/
+  public static boolean canHandle(RelOptTable relOptTable) {
+    Table table = relOptTable.unwrap(Table.class);
+    if (table != null && !canHandle(table)) {
+      return false;
+    }
+    boolean supportArray = CalciteSystemProperty.ENUMERABLE_ENABLE_TABLESCAN_ARRAY.value();
+    boolean supportMap = CalciteSystemProperty.ENUMERABLE_ENABLE_TABLESCAN_MAP.value();
+    boolean supportMultiset = CalciteSystemProperty.ENUMERABLE_ENABLE_TABLESCAN_MULTISET.value();
+    if (supportArray && supportMap && supportMultiset) {
+      return true;
+    }
+    // Struct fields are not supported in EnumerableTableScan
+    for (RelDataTypeField field : relOptTable.getRowType().getFieldList()) {
+      boolean unsupportedType = false;
+      switch (field.getType().getSqlTypeName()) {
+      case ARRAY:
+        unsupportedType = supportArray;
+        break;
+      case MAP:
 
 Review comment:
   Better move the type decision to `SqlTypeUtil`.

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