use of org.apache.calcite.materialize.Lattice in project calcite by apache.
the class ModelHandler method visit.
public void visit(JsonLattice jsonLattice) {
try {
checkRequiredAttributes(jsonLattice, "name", "sql");
final SchemaPlus schema = currentSchema();
if (!schema.isMutable()) {
throw new RuntimeException("Cannot define lattice; parent schema '" + currentSchemaName() + "' is not a SemiMutableSchema");
}
CalciteSchema calciteSchema = CalciteSchema.from(schema);
Lattice.Builder latticeBuilder = Lattice.builder(calciteSchema, jsonLattice.getSql()).auto(jsonLattice.auto).algorithm(jsonLattice.algorithm);
if (jsonLattice.rowCountEstimate != null) {
latticeBuilder.rowCountEstimate(jsonLattice.rowCountEstimate);
}
if (jsonLattice.statisticProvider != null) {
latticeBuilder.statisticProvider(jsonLattice.statisticProvider);
}
populateLattice(jsonLattice, latticeBuilder);
schema.add(jsonLattice.name, latticeBuilder.build());
} catch (Exception e) {
throw new RuntimeException("Error instantiating " + jsonLattice, e);
}
}
Aggregations