use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project hive by apache.
the class HiveSubQRemoveRelBuilder method scan.
// Methods that create relational expressions
/**
* Creates a {@link org.apache.calcite.rel.core.TableScan} of the table
* with a given name.
*
* <p>Throws if the table does not exist.
*
* <p>Returns this builder.
*
* @param tableNames Name of table (can optionally be qualified)
*/
public HiveSubQRemoveRelBuilder scan(Iterable<String> tableNames) {
final List<String> names = ImmutableList.copyOf(tableNames);
final RelOptTable relOptTable = relOptSchema.getTableForMember(names);
if (relOptTable == null) {
throw Static.RESOURCE.tableNotFound(Joiner.on(".").join(names)).ex();
}
final RelNode scan = scanFactory.createScan(cluster, relOptTable);
push(scan);
return this;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class TableScanNode method create.
/**
* 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");
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class RelMdColumnOrigins method getColumnOrigins.
// Catch-all rule when none of the others apply.
public Set<RelColumnOrigin> getColumnOrigins(RelNode rel, RelMetadataQuery mq, int iOutputColumn) {
if (rel.getInputs().size() > 0) {
// No generic logic available for non-leaf rels.
return null;
}
final Set<RelColumnOrigin> set = new HashSet<>();
RelOptTable table = rel.getTable();
if (table == null) {
// VALUES clause, so we return an empty set.
return set;
}
// rename as well.
if (table.getRowType() != rel.getRowType()) {
return null;
}
set.add(new RelColumnOrigin(table, iOutputColumn, false));
return set;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class LogicalTableScan method create.
/**
* Creates a LogicalTableScan.
*
* @param cluster Cluster
* @param relOptTable Table
*/
public static LogicalTableScan create(RelOptCluster cluster, final RelOptTable relOptTable) {
final Table table = relOptTable.unwrap(Table.class);
final RelTraitSet traitSet = cluster.traitSetOf(Convention.NONE).replaceIfs(RelCollationTraitDef.INSTANCE, new Supplier<List<RelCollation>>() {
public List<RelCollation> get() {
if (table != null) {
return table.getStatistic().getCollations();
}
return ImmutableList.of();
}
});
return new LogicalTableScan(cluster, traitSet, relOptTable);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptTable in project calcite by apache.
the class LoptOptimizeJoinRule method getSimpleFactors.
/**
* Retrieves join factors that correspond to simple table references. A
* simple table reference is a single table reference with no grouping or
* aggregation.
*
* @param multiJoin join factors being optimized
*
* @return map consisting of the simple factors and the tables they
* correspond
*/
private Map<Integer, RelOptTable> getSimpleFactors(RelMetadataQuery mq, LoptMultiJoin multiJoin) {
final Map<Integer, RelOptTable> returnList = new HashMap<>();
// are null-generating or will be removed because of semijoins.
if (multiJoin.getMultiJoinRel().isFullOuterJoin()) {
return returnList;
}
for (int factIdx = 0; factIdx < multiJoin.getNumJoinFactors(); factIdx++) {
if (multiJoin.isNullGenerating(factIdx) || (multiJoin.getJoinRemovalFactor(factIdx) != null)) {
continue;
}
final RelNode rel = multiJoin.getJoinFactor(factIdx);
final RelOptTable table = mq.getTableOrigin(rel);
if (table != null) {
returnList.put(factIdx, table);
}
}
return returnList;
}
Aggregations