use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project calcite by apache.
the class EnumerableTableScanRule method convert.
@Override
public RelNode convert(RelNode rel) {
LogicalTableScan scan = (LogicalTableScan) rel;
final RelOptTable relOptTable = scan.getTable();
final Table table = relOptTable.unwrap(Table.class);
if (!EnumerableTableScan.canHandle(table)) {
return null;
}
final Expression expression = relOptTable.getExpression(Object.class);
if (expression == null) {
return null;
}
return EnumerableTableScan.create(scan.getCluster(), relOptTable);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project calcite by apache.
the class CalciteSchema method getTablesBasedOnNullaryFunctions.
/**
* Returns tables derived from explicit and implicit functions
* that take zero parameters.
*/
public final NavigableMap<String, Table> getTablesBasedOnNullaryFunctions() {
ImmutableSortedMap.Builder<String, Table> builder = new ImmutableSortedMap.Builder<>(NameSet.COMPARATOR);
for (Map.Entry<String, FunctionEntry> entry : nullaryFunctionMap.map().entrySet()) {
final Function function = entry.getValue().getFunction();
if (function instanceof TableMacro) {
assert function.getParameters().isEmpty();
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(entry.getKey(), table);
}
}
// add tables derived from implicit functions
addImplicitTablesBasedOnNullaryFunctionsToBuilder(builder);
return Compatible.INSTANCE.navigableMap(builder.build());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project calcite by apache.
the class CachingCalciteSchema method getImplicitTable.
protected TableEntry getImplicitTable(String tableName, boolean caseSensitive) {
final long now = System.currentTimeMillis();
final NameSet implicitTableNames = implicitTableCache.get(now);
for (String tableName2 : implicitTableNames.range(tableName, caseSensitive)) {
final Table table = schema.getTable(tableName2);
if (table != null) {
return tableEntry(tableName2, table);
}
}
return null;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project calcite by apache.
the class CachingCalciteSchema method addImplicitTablesBasedOnNullaryFunctionsToBuilder.
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String s : set.iterable()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro && function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project calcite by apache.
the class CachingCalciteSchema method getImplicitTableBasedOnNullaryFunction.
protected TableEntry getImplicitTableBasedOnNullaryFunction(String tableName, boolean caseSensitive) {
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String s : set.range(tableName, caseSensitive)) {
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro && function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
return tableEntry(tableName, table);
}
}
}
return null;
}
Aggregations