Search in sources :

Example 1 with Queryable

use of org.apache.calcite.linq4j.Queryable in project calcite by apache.

the class Smalls method oneThreePlus.

private static QueryableTable oneThreePlus(String s) {
    List<Integer> items;
    // Then the engine calls a function with null arguments to get getRowType.
    if (s == null) {
        items = ImmutableList.of();
    } else {
        Integer latest = Integer.parseInt(s.substring(1, s.length() - 1));
        items = ImmutableList.of(1, 3, latest);
    }
    final Enumerable<Integer> enumerable = Linq4j.asEnumerable(items);
    return new AbstractQueryableTable(Integer.class) {

        public <E> Queryable<E> asQueryable(QueryProvider queryProvider, SchemaPlus schema, String tableName) {
            // noinspection unchecked
            return (Queryable<E>) enumerable.asQueryable();
        }

        public RelDataType getRowType(RelDataTypeFactory typeFactory) {
            return typeFactory.builder().add("c", SqlTypeName.INTEGER).build();
        }
    };
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AbstractQueryableTable(org.apache.calcite.adapter.java.AbstractQueryableTable) QueryProvider(org.apache.calcite.linq4j.QueryProvider) Queryable(org.apache.calcite.linq4j.Queryable) BaseQueryable(org.apache.calcite.linq4j.BaseQueryable) SchemaPlus(org.apache.calcite.schema.SchemaPlus) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AbstractQueryableTable (org.apache.calcite.adapter.java.AbstractQueryableTable)1 BaseQueryable (org.apache.calcite.linq4j.BaseQueryable)1 QueryProvider (org.apache.calcite.linq4j.QueryProvider)1 Queryable (org.apache.calcite.linq4j.Queryable)1 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1