use of org.apache.samza.sql.runner.SamzaSqlApplicationRunner in project samza by apache.
the class SamzaSqlConsole method executeSql.
public static void executeSql(List<String> sqlStmts) {
Map<String, String> staticConfigs = fetchSamzaSqlConfig();
staticConfigs.put(SamzaSqlApplicationConfig.CFG_SQL_STMTS_JSON, JsonUtil.toJson(sqlStmts));
SamzaSqlApplicationRunner runner = new SamzaSqlApplicationRunner(true, new MapConfig(staticConfigs));
runner.runAndWaitForFinish();
}
use of org.apache.samza.sql.runner.SamzaSqlApplicationRunner in project samza by apache.
the class SamzaExecutor method executeNonQuery.
@Override
public NonQueryResult executeNonQuery(ExecutionContext context, List<String> statement) throws ExecutorException {
int execId = execIdSeq.incrementAndGet();
Map<String, String> staticConfigs = fetchSamzaSqlConfig(execId);
staticConfigs.put(SamzaSqlApplicationConfig.CFG_SQL_STMTS_JSON, JsonUtil.toJson(formatSqlStmts(statement)));
SamzaSqlApplicationRunner runner;
try {
runner = new SamzaSqlApplicationRunner(true, new MapConfig(staticConfigs));
runner.run(null);
} catch (SamzaException ex) {
throw new ExecutorException(ex);
}
executions.put(execId, runner);
LOG.debug("Executing sql. Id ", execId);
return new NonQueryResult(execId);
}
use of org.apache.samza.sql.runner.SamzaSqlApplicationRunner in project samza by apache.
the class SamzaSqlIntegrationTestHarness method runApplication.
protected void runApplication(Config config) {
// Use MockSystemFactory for the coordinator system
MockSystemFactory.MSG_QUEUES.put(new SystemStreamPartition(MOCK_METADATA_SYSTEM, CoordinatorStreamUtil.getCoordinatorStreamName(SamzaSqlTestConfig.SQL_JOB, SamzaSqlTestConfig.SQL_JOB_PROCESSOR_ID), new Partition(0)), new ArrayList<>());
HashMap<String, String> mapConfig = new HashMap<>();
mapConfig.put(JobConfig.JOB_COORDINATOR_SYSTEM, MOCK_METADATA_SYSTEM);
mapConfig.put(String.format(SystemConfig.SYSTEM_FACTORY_FORMAT, MOCK_METADATA_SYSTEM), MockSystemFactory.class.getName());
// configs for using in-memory system as the default system
mapConfig.putAll(baseInMemorySystemConfigs());
mapConfig.putAll(config);
SamzaSqlApplicationRunner runner = new SamzaSqlApplicationRunner(true, new MapConfig(mapConfig));
executeRun(runner, config);
runner.waitForFinish();
}
use of org.apache.samza.sql.runner.SamzaSqlApplicationRunner in project samza by apache.
the class SamzaExecutor method executeQuery.
@Override
public QueryResult executeQuery(ExecutionContext context, String statement) throws ExecutorException {
outputData.clear();
int execId = execIdSeq.incrementAndGet();
Map<String, String> staticConfigs = fetchSamzaSqlConfig(execId);
List<String> sqlStmts = formatSqlStmts(Collections.singletonList(statement));
staticConfigs.put(SamzaSqlApplicationConfig.CFG_SQL_STMTS_JSON, JsonUtil.toJson(sqlStmts));
SamzaSqlApplicationRunner runner;
try {
runner = new SamzaSqlApplicationRunner(true, new MapConfig(staticConfigs));
runner.run(null);
} catch (SamzaException ex) {
throw new ExecutorException(ex);
}
executions.put(execId, runner);
LOG.debug("Executing sql. Id ", execId);
SqlSchema resultSchema = null;
// resultSchema = generateResultSchema(new MapConfig(staticConfigs));
return new QueryResult(execId, resultSchema);
}
Aggregations