Search in sources :

Example 1 with TablesTable

use of com.hazelcast.jet.sql.impl.connector.infoschema.TablesTable in project hazelcast by hazelcast.

the class TableResolverImpl method getTables.

@Nonnull
@Override
public List<Table> getTables() {
    Collection<Object> objects = tableStorage.allObjects();
    List<Table> tables = new ArrayList<>(objects.size() + 3);
    for (Object o : objects) {
        if (o instanceof Mapping) {
            tables.add(toTable((Mapping) o));
        } else if (o instanceof View) {
            tables.add(toTable((View) o));
        } else {
            throw new RuntimeException("Unexpected: " + o);
        }
    }
    Collection<Mapping> mappings = objects.stream().filter(o -> o instanceof Mapping).map(m -> (Mapping) m).collect(Collectors.toList());
    Collection<View> views = objects.stream().filter(o -> o instanceof View).map(v -> (View) v).collect(Collectors.toList());
    tables.add(new TablesTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, mappings, views));
    tables.add(new MappingsTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, mappings));
    tables.add(new MappingColumnsTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, mappings, views));
    tables.add(new ViewsTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, views));
    return tables;
}
Also used : SqlConnectorCache(com.hazelcast.jet.sql.impl.connector.SqlConnectorCache) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) LinkedHashMap(java.util.LinkedHashMap) ViewsTable(com.hazelcast.jet.sql.impl.connector.infoschema.ViewsTable) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics) SqlConnector(com.hazelcast.jet.sql.impl.connector.SqlConnector) MappingsTable(com.hazelcast.jet.sql.impl.connector.infoschema.MappingsTable) View(com.hazelcast.sql.impl.schema.view.View) Nonnull(javax.annotation.Nonnull) QueryException(com.hazelcast.sql.impl.QueryException) EntryEvent(com.hazelcast.core.EntryEvent) ViewTable(com.hazelcast.jet.sql.impl.connector.virtual.ViewTable) NodeEngine(com.hazelcast.spi.impl.NodeEngine) Collection(java.util.Collection) MappingColumnsTable(com.hazelcast.jet.sql.impl.connector.infoschema.MappingColumnsTable) Collectors(java.util.stream.Collectors) Mapping(com.hazelcast.sql.impl.schema.Mapping) TableField(com.hazelcast.sql.impl.schema.TableField) TablesTable(com.hazelcast.jet.sql.impl.connector.infoschema.TablesTable) TableResolver(com.hazelcast.sql.impl.schema.TableResolver) List(java.util.List) CATALOG(com.hazelcast.sql.impl.QueryUtils.CATALOG) MappingField(com.hazelcast.sql.impl.schema.MappingField) Table(com.hazelcast.sql.impl.schema.Table) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ViewsTable(com.hazelcast.jet.sql.impl.connector.infoschema.ViewsTable) MappingsTable(com.hazelcast.jet.sql.impl.connector.infoschema.MappingsTable) ViewTable(com.hazelcast.jet.sql.impl.connector.virtual.ViewTable) MappingColumnsTable(com.hazelcast.jet.sql.impl.connector.infoschema.MappingColumnsTable) TablesTable(com.hazelcast.jet.sql.impl.connector.infoschema.TablesTable) Table(com.hazelcast.sql.impl.schema.Table) ViewsTable(com.hazelcast.jet.sql.impl.connector.infoschema.ViewsTable) TablesTable(com.hazelcast.jet.sql.impl.connector.infoschema.TablesTable) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Mapping(com.hazelcast.sql.impl.schema.Mapping) View(com.hazelcast.sql.impl.schema.view.View) MappingsTable(com.hazelcast.jet.sql.impl.connector.infoschema.MappingsTable) MappingColumnsTable(com.hazelcast.jet.sql.impl.connector.infoschema.MappingColumnsTable) Nonnull(javax.annotation.Nonnull)

Aggregations

EntryEvent (com.hazelcast.core.EntryEvent)1 SqlConnector (com.hazelcast.jet.sql.impl.connector.SqlConnector)1 SqlConnectorCache (com.hazelcast.jet.sql.impl.connector.SqlConnectorCache)1 MappingColumnsTable (com.hazelcast.jet.sql.impl.connector.infoschema.MappingColumnsTable)1 MappingsTable (com.hazelcast.jet.sql.impl.connector.infoschema.MappingsTable)1 TablesTable (com.hazelcast.jet.sql.impl.connector.infoschema.TablesTable)1 ViewsTable (com.hazelcast.jet.sql.impl.connector.infoschema.ViewsTable)1 ViewTable (com.hazelcast.jet.sql.impl.connector.virtual.ViewTable)1 NodeEngine (com.hazelcast.spi.impl.NodeEngine)1 QueryException (com.hazelcast.sql.impl.QueryException)1 CATALOG (com.hazelcast.sql.impl.QueryUtils.CATALOG)1 ConstantTableStatistics (com.hazelcast.sql.impl.schema.ConstantTableStatistics)1 Mapping (com.hazelcast.sql.impl.schema.Mapping)1 MappingField (com.hazelcast.sql.impl.schema.MappingField)1 Table (com.hazelcast.sql.impl.schema.Table)1 TableField (com.hazelcast.sql.impl.schema.TableField)1 TableResolver (com.hazelcast.sql.impl.schema.TableResolver)1 View (com.hazelcast.sql.impl.schema.view.View)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1