Search in sources :

Example 66 with Table

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project drill by apache.

the class AbstractSchema method getTablesByNames.

/**
   * Get the collection of {@link Table} tables specified in the tableNames.
   *
   * @param  tableNames the requested tables, specified by the table names
   * @return the collection of requested tables
   */
public List<Pair<String, ? extends Table>> getTablesByNames(final List<String> tableNames) {
    final List<Pair<String, ? extends Table>> tables = Lists.newArrayList();
    for (String tableName : tableNames) {
        final Table table = getTable(tableName);
        if (table == null) {
            // tables as INFO SCHEMA is about showing tables which the use has access to query.
            continue;
        }
        tables.add(Pair.of(tableName, table));
    }
    return tables;
}
Also used : Table(org.apache.calcite.schema.Table) Pair(org.apache.commons.lang3.tuple.Pair)

Example 67 with Table

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project lucene-solr by apache.

the class SolrSchema method getTableMap.

@Override
protected Map<String, Table> getTableMap() {
    String zk = this.properties.getProperty("zk");
    try (CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zk).build()) {
        cloudSolrClient.connect();
        ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
        ClusterState clusterState = zkStateReader.getClusterState();
        final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
        for (String collection : clusterState.getCollectionsMap().keySet()) {
            builder.put(collection, new SolrTable(this, collection));
        }
        Aliases aliases = zkStateReader.getAliases();
        if (aliases.collectionAliasSize() > 0) {
            for (Map.Entry<String, String> alias : aliases.getCollectionAliasMap().entrySet()) {
                builder.put(alias.getKey(), new SolrTable(this, alias.getValue()));
            }
        }
        return builder.build();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ClusterState(org.apache.solr.common.cloud.ClusterState) Table(org.apache.calcite.schema.Table) Aliases(org.apache.solr.common.cloud.Aliases) IOException(java.io.IOException) ImmutableMap(com.google.common.collect.ImmutableMap) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) ZkStateReader(org.apache.solr.common.cloud.ZkStateReader) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 68 with Table

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project drill by axbaretto.

the class AbstractSchema method getTablesByNames.

/**
 * Get the collection of {@link Table} tables specified in the tableNames.
 *
 * @param  tableNames the requested tables, specified by the table names
 * @return the collection of requested tables
 */
public List<Pair<String, ? extends Table>> getTablesByNames(final List<String> tableNames) {
    final List<Pair<String, ? extends Table>> tables = Lists.newArrayList();
    for (String tableName : tableNames) {
        final Table table = getTable(tableName);
        if (table == null) {
            // tables as INFO SCHEMA is about showing tables which the use has access to query.
            continue;
        }
        tables.add(Pair.of(tableName, table));
    }
    return tables;
}
Also used : Table(org.apache.calcite.schema.Table) Pair(org.apache.commons.lang3.tuple.Pair)

Example 69 with Table

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project drill by axbaretto.

the class DirPrunedEnumerableTableScan method create.

/**
 * Creates an DirPrunedEnumerableTableScan.
 */
public static EnumerableTableScan create(RelOptCluster cluster, RelOptTable relOptTable, String digestFromSelection) {
    final Table table = relOptTable.unwrap(Table.class);
    Class elementType = EnumerableTableScan.deduceElementType(table);
    final RelTraitSet traitSet = cluster.traitSetOf(EnumerableConvention.INSTANCE).replaceIfs(RelCollationTraitDef.INSTANCE, new Supplier<List<RelCollation>>() {

        public List<RelCollation> get() {
            if (table != null) {
                return table.getStatistic().getCollations();
            }
            return ImmutableList.of();
        }
    });
    return new DirPrunedEnumerableTableScan(cluster, traitSet, relOptTable, elementType, digestFromSelection);
}
Also used : Table(org.apache.calcite.schema.Table) RelOptTable(org.apache.calcite.plan.RelOptTable) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 70 with Table

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.Table in project drill by axbaretto.

the class DirPrunedEnumerableTableScan method copy.

@Override
public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) {
    final Table tbl = this.table.unwrap(Table.class);
    Class elementType = EnumerableTableScan.deduceElementType(tbl);
    return new DirPrunedEnumerableTableScan(getCluster(), traitSet, table, elementType, digestFromSelection);
}
Also used : Table(org.apache.calcite.schema.Table) RelOptTable(org.apache.calcite.plan.RelOptTable)

Aggregations

Table (org.apache.calcite.schema.Table)104 Test (org.junit.Test)43 SqlStdOperatorTable (org.apache.calcite.sql.fun.SqlStdOperatorTable)38 RelOptTable (org.apache.calcite.plan.RelOptTable)33 RelDataType (org.apache.calcite.rel.type.RelDataType)22 SqlOperatorTable (org.apache.calcite.sql.SqlOperatorTable)22 SchemaPlus (org.apache.calcite.schema.SchemaPlus)20 ArrayList (java.util.ArrayList)19 List (java.util.List)19 ProjectableFilterableTable (org.apache.calcite.schema.ProjectableFilterableTable)17 ScannableTable (org.apache.calcite.schema.ScannableTable)17 JavaTypeFactoryImpl (org.apache.calcite.jdbc.JavaTypeFactoryImpl)16 FilterableTable (org.apache.calcite.schema.FilterableTable)15 AbstractTable (org.apache.calcite.schema.impl.AbstractTable)15 ResultSet (java.sql.ResultSet)14 Schema (org.apache.beam.sdk.schemas.Schema)14 Row (org.apache.beam.sdk.values.Row)14 StreamableTable (org.apache.calcite.schema.StreamableTable)14 CalciteConnection (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.CalciteConnection)13 Map (java.util.Map)12