Search in sources :

Example 1 with TableFactory

use of org.apache.calcite.schema.TableFactory in project calcite by apache.

the class ModelHandler method visit.

public void visit(JsonCustomTable jsonTable) {
    try {
        checkRequiredAttributes(jsonTable, "name", "factory");
        final SchemaPlus schema = currentMutableSchema("table");
        final TableFactory tableFactory = AvaticaUtils.instantiatePlugin(TableFactory.class, jsonTable.factory);
        final Table table = tableFactory.create(schema, jsonTable.name, operandMap(null, jsonTable.operand), null);
        for (JsonColumn column : jsonTable.columns) {
            column.accept(this);
        }
        schema.add(jsonTable.name, table);
    } catch (Exception e) {
        throw new RuntimeException("Error instantiating " + jsonTable, e);
    }
}
Also used : ViewTable(org.apache.calcite.schema.impl.ViewTable) MaterializedViewTable(org.apache.calcite.schema.impl.MaterializedViewTable) Table(org.apache.calcite.schema.Table) TableFactory(org.apache.calcite.schema.TableFactory) SchemaPlus(org.apache.calcite.schema.SchemaPlus) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1 Table (org.apache.calcite.schema.Table)1 TableFactory (org.apache.calcite.schema.TableFactory)1 MaterializedViewTable (org.apache.calcite.schema.impl.MaterializedViewTable)1 ViewTable (org.apache.calcite.schema.impl.ViewTable)1