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:
[email protected]


Reply via email to