use of org.apache.calcite.linq4j.function.Experimental in project calcite by apache.
the class RelBuilder method repeatUnion.
/**
* Creates a {@link RepeatUnion} associated to a {@link TransientTable} of the
* two most recent relational expressions on the stack.
*
* <p>Warning: if these relational expressions are not
* correctly defined, this operation might lead to an infinite loop.
*
* <p>The generated {@link RepeatUnion} operates as follows:
*
* <ul>
* <li>Evaluate its left term once, propagating the results into the
* {@link TransientTable};
* <li>Evaluate its right term (which may contain a {@link TableScan} on the
* {@link TransientTable}) over and over until it produces no more results
* (or until an optional maximum number of iterations is reached). On each
* iteration, the results are propagated into the {@link TransientTable},
* overwriting the results from the previous one.
* </ul>
*
* @param tableName Name of the {@link TransientTable} associated to the
* {@link RepeatUnion}
* @param all Whether duplicates are considered
* @param iterationLimit Maximum number of iterations; negative value means no limit
*/
@Experimental
public RelBuilder repeatUnion(String tableName, boolean all, int iterationLimit) {
RelOptTableFinder finder = new RelOptTableFinder(tableName);
for (int i = 0; i < stack.size(); i++) {
// search scan(tableName) in the stack
peek(i).accept(finder);
if (finder.relOptTable != null) {
// found
break;
}
}
if (finder.relOptTable == null) {
throw RESOURCE.tableNotFound(tableName).ex();
}
RelNode iterative = tableSpool(Spool.Type.LAZY, Spool.Type.LAZY, finder.relOptTable).build();
RelNode seed = tableSpool(Spool.Type.LAZY, Spool.Type.LAZY, finder.relOptTable).build();
RelNode repeatUnion = struct.repeatUnionFactory.createRepeatUnion(seed, iterative, all, iterationLimit, finder.relOptTable);
return push(repeatUnion);
}
use of org.apache.calcite.linq4j.function.Experimental in project calcite by apache.
the class RelBuilder method transientScan.
/**
* Creates a {@link TableScan} on a {@link TransientTable} with the given name and type.
*
* @param tableName table name
* @param rowType row type of the table
*/
@Experimental
public RelBuilder transientScan(String tableName, RelDataType rowType) {
TransientTable transientTable = new ListTransientTable(tableName, rowType);
requireNonNull(relOptSchema, "relOptSchema");
RelOptTable relOptTable = RelOptTableImpl.create(relOptSchema, rowType, transientTable, ImmutableList.of(tableName));
RelNode scan = struct.scanFactory.createScan(ViewExpanders.toRelContext(viewExpander, cluster), relOptTable);
push(scan);
rename(rowType.getFieldNames());
return this;
}
Aggregations