Java Code Examples for org.apache.calcite.rel.core.TableScan#getTable()
The following examples show how to use
org.apache.calcite.rel.core.TableScan#getTable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamRules.java From Bats with Apache License 2.0 | 6 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); final TableScan scan = call.rel(1); final RelOptCluster cluster = delta.getCluster(); final RelOptTable relOptTable = scan.getTable(); final StreamableTable streamableTable = relOptTable.unwrap(StreamableTable.class); if (streamableTable != null) { final Table table1 = streamableTable.stream(); final RelOptTable relOptTable2 = RelOptTableImpl.create(relOptTable.getRelOptSchema(), relOptTable.getRowType(), table1, ImmutableList.<String>builder() .addAll(relOptTable.getQualifiedName()) .add("(STREAM)").build()); final LogicalTableScan newScan = LogicalTableScan.create(cluster, relOptTable2); call.transformTo(newScan); } }
Example 2
Source File: RelMdColumnOrigins.java From dremio-oss with Apache License 2.0 | 6 votes |
public Set<RelColumnOrigin> getColumnOrigins(TableScan tableScan, RelMetadataQuery mq, int iOutputColumn) { final Set<RelColumnOrigin> set = new HashSet<>(); RelOptTable table = tableScan.getTable(); if (table == null) { return null; } if (table.getRowType() != tableScan.getRowType()) { String columnName = tableScan.getRowType().getFieldNames().get(iOutputColumn); int newOutputColumn = 0; for (String tableCol : table.getRowType().getFieldNames()) { if (tableCol.equals(columnName)) { set.add(new RelColumnOrigin(table, newOutputColumn, false)); return set; } newOutputColumn++; } } else { set.add(new RelColumnOrigin(table, iOutputColumn, false)); } return set; }
Example 3
Source File: StreamRules.java From calcite with Apache License 2.0 | 6 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); final TableScan scan = call.rel(1); final RelOptCluster cluster = delta.getCluster(); final RelOptTable relOptTable = scan.getTable(); final StreamableTable streamableTable = relOptTable.unwrap(StreamableTable.class); if (streamableTable != null) { final Table table1 = streamableTable.stream(); final RelOptTable relOptTable2 = RelOptTableImpl.create(relOptTable.getRelOptSchema(), relOptTable.getRowType(), table1, ImmutableList.<String>builder() .addAll(relOptTable.getQualifiedName()) .add("(STREAM)").build()); final LogicalTableScan newScan = LogicalTableScan.create(cluster, relOptTable2, scan.getHints()); call.transformTo(newScan); } }
Example 4
Source File: StreamRules.java From Bats with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); final TableScan scan = call.rel(1); final RelOptTable relOptTable = scan.getTable(); final StreamableTable streamableTable = relOptTable.unwrap(StreamableTable.class); final RelBuilder builder = call.builder(); if (streamableTable == null) { call.transformTo(builder.values(delta.getRowType()).build()); } }
Example 5
Source File: HBTQueryConvertor.java From Mycat2 with GNU General Public License v3.0 | 5 votes |
public RelNode filterFromTable(FilterFromTableSchema input) { List<String> names = input.getNames(); relBuilder.scan(names); TableScan tableScan = (TableScan) relBuilder.peek(); RelOptTable table = tableScan.getTable(); relBuilder.as(names.get(names.size() - 1)); relBuilder.filter(toRex(input.getFilter())); Filter build = (Filter) relBuilder.build(); Bindables.BindableTableScan bindableTableScan = Bindables.BindableTableScan.create(build.getCluster(), table, build.getChildExps(), TableScan.identity(table)); relBuilder.clear(); return PushDownLogicTableRule.BindableTableScan.toPhyTable(relBuilder, bindableTableScan); }
Example 6
Source File: StreamRules.java From calcite with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall call) { final Delta delta = call.rel(0); final TableScan scan = call.rel(1); final RelOptTable relOptTable = scan.getTable(); final StreamableTable streamableTable = relOptTable.unwrap(StreamableTable.class); final RelBuilder builder = call.builder(); if (streamableTable == null) { call.transformTo(builder.values(delta.getRowType()).build()); } }
Example 7
Source File: FilterTableScanRule.java From calcite with Apache License 2.0 | 5 votes |
public static boolean test(TableScan scan) { // We can only push filters into a FilterableTable or // ProjectableFilterableTable. final RelOptTable table = scan.getTable(); return table.unwrap(FilterableTable.class) != null || table.unwrap(ProjectableFilterableTable.class) != null; }
Example 8
Source File: RelBuilder.java From calcite with Apache License 2.0 | 5 votes |
@Override public RelNode visit(TableScan scan) { final RelOptTable scanTable = scan.getTable(); final List<String> qualifiedName = scanTable.getQualifiedName(); if (qualifiedName.get(qualifiedName.size() - 1).equals(tableName)) { relOptTable = scanTable; } return super.visit(scan); }
Example 9
Source File: TableScanNode.java From calcite with Apache License 2.0 | 5 votes |
/** Creates a TableScanNode. * * <p>Tries various table SPIs, and negotiates with the table which filters * and projects it can implement. Adds to the Enumerable implementations of * any filters and projects that cannot be implemented by the table. */ static TableScanNode create(Compiler compiler, TableScan rel, ImmutableList<RexNode> filters, ImmutableIntList projects) { final RelOptTable relOptTable = rel.getTable(); final ProjectableFilterableTable pfTable = relOptTable.unwrap(ProjectableFilterableTable.class); if (pfTable != null) { return createProjectableFilterable(compiler, rel, filters, projects, pfTable); } final FilterableTable filterableTable = relOptTable.unwrap(FilterableTable.class); if (filterableTable != null) { return createFilterable(compiler, rel, filters, projects, filterableTable); } final ScannableTable scannableTable = relOptTable.unwrap(ScannableTable.class); if (scannableTable != null) { return createScannable(compiler, rel, filters, projects, scannableTable); } //noinspection unchecked final Enumerable<Row> enumerable = relOptTable.unwrap(Enumerable.class); if (enumerable != null) { return createEnumerable(compiler, rel, enumerable, null, filters, projects); } final QueryableTable queryableTable = relOptTable.unwrap(QueryableTable.class); if (queryableTable != null) { return createQueryable(compiler, rel, filters, projects, queryableTable); } throw new AssertionError("cannot convert table " + relOptTable + " to enumerable"); }
Example 10
Source File: FilterTableScanRule.java From Bats with Apache License 2.0 | 4 votes |
public static boolean test(TableScan scan) { // We can only push filters into a FilterableTable or // ProjectableFilterableTable. final RelOptTable table = scan.getTable(); return table.unwrap(FilterableTable.class) != null; }
Example 11
Source File: ProjectTableScanRule.java From calcite with Apache License 2.0 | 4 votes |
protected static boolean test(TableScan scan) { // We can only push projects into a ProjectableFilterableTable. final RelOptTable table = scan.getTable(); return table.unwrap(ProjectableFilterableTable.class) != null; }
Example 12
Source File: DrillPushProjectIntoScanRule.java From Bats with Apache License 2.0 | 3 votes |
/** * Creates new {@code DrillScanRelBase} instance with row type and fields list * obtained from specified {@code ProjectPushInfo projectPushInfo} * using specified {@code TableScan scan} as prototype. * * @param scan the prototype of resulting scan * @param projectPushInfo the source of row type and fields list * @return new scan instance */ protected DrillScanRelBase createScan(TableScan scan, ProjectPushInfo projectPushInfo) { return new DrillScanRel(scan.getCluster(), scan.getTraitSet().plus(DrillRel.DRILL_LOGICAL), scan.getTable(), projectPushInfo.createNewRowType(scan.getCluster().getTypeFactory()), projectPushInfo.getFields()); }