Creates a TableScan of the table with a given name. Throws if the table does not exist. Returns this builder. @param tableNames Name of table (can optionally be qualified)
(Iterable<String> tableNames)
| 1785 | * @param tableNames Name of table (can optionally be qualified) |
| 1786 | */ |
| 1787 | public RelBuilder scan(Iterable<String> tableNames) { |
| 1788 | final List<String> names = ImmutableList.copyOf(tableNames); |
| 1789 | requireNonNull(relOptSchema, "relOptSchema"); |
| 1790 | final RelOptTable relOptTable = relOptSchema.getTableForMember(names); |
| 1791 | if (relOptTable == null) { |
| 1792 | throw RESOURCE.tableNotFound(String.join(".", names)).ex(); |
| 1793 | } |
| 1794 | final RelNode scan = |
| 1795 | struct.scanFactory.createScan( |
| 1796 | ViewExpanders.toRelContext(viewExpander, cluster), |
| 1797 | relOptTable); |
| 1798 | push(scan); |
| 1799 | rename(relOptTable.getRowType().getFieldNames()); |
| 1800 | |
| 1801 | // When the node is not a TableScan but from expansion, |
| 1802 | // we need to explicitly add the alias. |
| 1803 | if (!(scan instanceof TableScan)) { |
| 1804 | as(Util.last(ImmutableList.copyOf(tableNames))); |
| 1805 | } |
| 1806 | return this; |
| 1807 | } |
| 1808 | |
| 1809 | /** Creates a {@link TableScan} of the table |
| 1810 | * with a given name. |