Search in sources :

Example 1 with AbstractTableQueryable

use of org.apache.calcite.schema.impl.AbstractTableQueryable in project calcite by apache.

the class QueryableRelBuilder method toRel.

RelNode toRel(Queryable<T> queryable) {
    if (queryable instanceof QueryableDefaults.Replayable) {
        // noinspection unchecked
        ((QueryableDefaults.Replayable) queryable).replay(this);
        return rel;
    }
    if (queryable instanceof AbstractTableQueryable) {
        final AbstractTableQueryable tableQueryable = (AbstractTableQueryable) queryable;
        final QueryableTable table = tableQueryable.table;
        final CalciteSchema.TableEntry tableEntry = CalciteSchema.from(tableQueryable.schema).add(tableQueryable.tableName, tableQueryable.table);
        final RelOptTableImpl relOptTable = RelOptTableImpl.create(null, table.getRowType(translator.typeFactory), tableEntry, null);
        if (table instanceof TranslatableTable) {
            return ((TranslatableTable) table).toRel(translator, relOptTable);
        } else {
            return LogicalTableScan.create(translator.cluster, relOptTable);
        }
    }
    return translator.translate(queryable.getExpression());
}
Also used : QueryableTable(org.apache.calcite.schema.QueryableTable) CalciteSchema(org.apache.calcite.jdbc.CalciteSchema) TranslatableTable(org.apache.calcite.schema.TranslatableTable) AbstractTableQueryable(org.apache.calcite.schema.impl.AbstractTableQueryable)

Aggregations

CalciteSchema (org.apache.calcite.jdbc.CalciteSchema)1 QueryableTable (org.apache.calcite.schema.QueryableTable)1 TranslatableTable (org.apache.calcite.schema.TranslatableTable)1 AbstractTableQueryable (org.apache.calcite.schema.impl.AbstractTableQueryable)1