use of org.apache.storm.sql.runtime.DataSource in project storm by apache.
the class StormSqlImpl method handleCreateTable.
private void handleCreateTable(SqlCreateTable n, Map<String, DataSource> dataSources) {
List<FieldInfo> fields = updateSchema(n);
DataSource ds = DataSourcesRegistry.construct(n.location(), n.inputFormatClass(), n.outputFormatClass(), fields);
if (ds == null) {
throw new RuntimeException("Cannot construct data source for " + n.tableName());
} else if (dataSources.containsKey(n.tableName())) {
throw new RuntimeException("Duplicated definition for table " + n.tableName());
}
dataSources.put(n.tableName(), ds);
}
use of org.apache.storm.sql.runtime.DataSource in project storm by apache.
the class TestExprSemantic method testExpr.
private Values testExpr(List<String> exprs) throws Exception {
String sql = "SELECT " + Joiner.on(',').join(exprs) + " FROM FOO" + " WHERE ID > 0 AND ID < 2";
TestCompilerUtils.CalciteState state = TestCompilerUtils.sqlOverDummyTable(sql);
PlanCompiler compiler = new PlanCompiler(typeFactory);
AbstractValuesProcessor proc = compiler.compile(state.tree());
Map<String, DataSource> data = new HashMap<>();
data.put("FOO", new TestUtils.MockDataSource());
List<Values> values = new ArrayList<>();
ChannelHandler h = new TestUtils.CollectDataChannelHandler(values);
proc.initialize(data, h);
return values.get(0);
}
Aggregations