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/11/06 19:43:28 UTC

[GitHub] [calcite] julianhyde opened a new pull request #2248: [CALCITE-4366] LatticeSuggester should treat UNION and VALUES sub-expressions as tables

julianhyde opened a new pull request #2248:
URL: https://github.com/apache/calcite/pull/2248


   


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



[GitHub] [calcite] vlsi commented on pull request #2248: [CALCITE-4366] LatticeSuggester should treat UNION and VALUES sub-expressions as tables

Posted by GitBox <gi...@apache.org>.
vlsi commented on pull request #2248:
URL: https://github.com/apache/calcite/pull/2248#issuecomment-723269896


   @julianhyde , Could you please refrain from adding `@Nonnull`?
   It should be a default mode, so there's no point in adding `@Nonnull`.
   
   It would be nice if you could annotate `nullable` (e.g. in case you expect something to receive or return null)


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



[GitHub] [calcite] julianhyde commented on a change in pull request #2248: [CALCITE-4366] LatticeSuggester should treat UNION and VALUES sub-expressions as tables

Posted by GitBox <gi...@apache.org>.
julianhyde commented on a change in pull request #2248:
URL: https://github.com/apache/calcite/pull/2248#discussion_r532960754



##########
File path: core/src/main/java/org/apache/calcite/materialize/LatticeSuggester.java
##########
@@ -526,13 +551,39 @@ private ColRef toColRef(RexNode e, String alias) {
     } else if (r instanceof TableScan) {
       final TableScan scan = (TableScan) r;
       final TableRef tableRef = q.tableRef(scan);
-      final int fieldCount = r.getRowType().getFieldCount();
-      return new Frame(fieldCount, ImmutableList.of(),
+      final RelDataType rowType = r.getRowType();
+      return new Frame(rowType.getFieldCount(), ImmutableList.of(),
           ImmutableList.of(), ImmutableSet.of(tableRef)) {
         @Override ColRef column(int offset) {
-          if (offset >= scan.getTable().getRowType().getFieldCount()) {
+          if (offset >= rowType.getFieldCount()) {
             throw new IndexOutOfBoundsException("field " + offset
-                + " out of range in " + scan.getTable().getRowType());
+                + " out of range in " + rowType);
+          }
+          return new BaseColRef(tableRef, offset);
+        }
+      };
+    } else if (r instanceof TableFunctionScan) {

Review comment:
       Ideally, you would throw away your code and move the logic into `LatticeSuggester`.
   
   But failing that, use a `TableFunctionScan` that calls the WRAP function. Calls to any other table function will not be treated as wrappers.




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