use of org.apache.calcite.schema.Schema in project hazelcast by hazelcast.
the class HazelcastSchemaUtils method createRootSchema.
/**
* Construct a schema from the given table resolvers.
* <p>
* Currently we assume that all tables are resolved upfront by querying a table resolver. It works well for predefined
* objects such as IMap and ReplicatedMap as well as external tables created by Jet. This approach will not work well
* should we need a relaxed/dynamic object resolution at some point in future.
*
* @return Top-level schema.
*/
public static HazelcastSchema createRootSchema(SqlCatalog catalog) {
// Create schemas.
Map<String, Schema> schemaMap = new HashMap<>();
for (Map.Entry<String, Map<String, Table>> currentSchemaEntry : catalog.getSchemas().entrySet()) {
String schemaName = currentSchemaEntry.getKey();
Map<String, org.apache.calcite.schema.Table> schemaTables = new HashMap<>();
for (Map.Entry<String, Table> tableEntry : currentSchemaEntry.getValue().entrySet()) {
String tableName = tableEntry.getKey();
Table table = tableEntry.getValue();
HazelcastTable convertedTable = new HazelcastTable(table, createTableStatistic(table));
schemaTables.put(tableName, convertedTable);
}
HazelcastSchema currentSchema = new HazelcastSchema(Collections.emptyMap(), schemaTables);
schemaMap.put(schemaName, currentSchema);
}
HazelcastSchema rootSchema = new HazelcastSchema(schemaMap, Collections.emptyMap());
return createCatalog(rootSchema);
}
Aggregations