Tabnine Logo
SamzaSqlApplicationRunner.computeSamzaConfigs
Code IndexAdd Tabnine to your IDE (free)

How to use
computeSamzaConfigs
method
in
org.apache.samza.sql.runner.SamzaSqlApplicationRunner

Best Java code snippets using org.apache.samza.sql.runner.SamzaSqlApplicationRunner.computeSamzaConfigs (Showing top 20 results out of 315)

origin: apache/samza

private SamzaSqlApplicationRunner(SamzaApplication app, Boolean localRunner, Config config) {
 this.runner = ApplicationRunners.getApplicationRunner(app, computeSamzaConfigs(localRunner, config));
}
origin: org.apache.samza/samza-sql

private SamzaSqlApplicationRunner(SamzaApplication app, Boolean localRunner, Config config) {
 this.runner = ApplicationRunners.getApplicationRunner(app, computeSamzaConfigs(localRunner, config));
}
origin: apache/samza

 @Test
 public void testComputeSamzaConfigs() {
  Map<String, String> configs = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(10);
  String sql1 = "Insert into testavro.outputTopic(id,long_value) select id, MyTest(id) as long_value from testavro.SIMPLE1";
  configs.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql1);
  configs.put(SamzaSqlApplicationRunner.RUNNER_CONFIG, SamzaSqlApplicationRunner.class.getName());
  MapConfig samzaConfig = new MapConfig(configs);
  Config newConfigs = SamzaSqlApplicationRunner.computeSamzaConfigs(true, samzaConfig);
  Assert.assertEquals(newConfigs.get(SamzaSqlApplicationRunner.RUNNER_CONFIG), LocalApplicationRunner.class.getName());
  // Check whether five new configs added.
  Assert.assertEquals(newConfigs.size(), configs.size() + 5);

  newConfigs = SamzaSqlApplicationRunner.computeSamzaConfigs(false, samzaConfig);
  Assert.assertEquals(newConfigs.get(SamzaSqlApplicationRunner.RUNNER_CONFIG), RemoteApplicationRunner.class.getName());

  // Check whether five new configs added.
  Assert.assertEquals(newConfigs.size(), configs.size() + 5);
 }
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableJoinWithSubQuery() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv"
     + " where exists "
     + " (select p.id from testavro.PROFILE.`$table` as p"
     + " where p.id = pv.profileId)";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableCrossJoin() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv, testavro.PROFILE.`$table` as p";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableJoinWithFullJoinOperator() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv"
     + " full join testavro.PROFILE.`$table` as p"
     + " on p.id = pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateTableTableJoin() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW.`$table` as pv"
     + " join testavro.PROFILE.`$table` as p"
     + " on p.id = pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableInnerJoinWithMissingStream() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 10);
 String configIOResolverDomain =
   String.format(SamzaSqlApplicationConfig.CFG_FMT_SOURCE_RESOLVER_DOMAIN, "config");
 config.put(configIOResolverDomain + SamzaSqlApplicationConfig.CFG_FACTORY,
   ConfigBasedIOResolverFactory.class.getName());
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv"
     + " join testavro.`$table` as p"
     + " on p.id = pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableJoinWithoutJoinOperator() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv, testavro.PROFILE.`$table` as p"
     + " where p.id = pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamStreamJoin() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv"
     + " join testavro.PROFILE as p"
     + " on p.id = pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateJoinWithIncorrectLeftJoin() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW.`$table` as pv"
     + " left join testavro.PROFILE as p"
     + " on p.id = pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

 @Test (expected = SamzaException.class)
 public void testTranslateGroupByWithSumAggregator() {
  Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 10);
  String sql =
    "Insert into testavro.pageViewCountTopic(jobName, pageKey, `sum`)"
      + " select 'SampleJob' as jobName, pv.pageKey, sum(pv.profileId) as `sum`"
      + " from testavro.PAGEVIEW as pv" + " where pv.pageKey = 'job' or pv.pageKey = 'inbox'"
      + " group by (pv.pageKey)";
  config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
  Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));

  List<String> sqlStmts = fetchSqlFromConfig(config);
  List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
  SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
    queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
      .collect(Collectors.toList()),
    queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));

  StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
  QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
  translator.translate(queryInfo.get(0), streamAppDesc, 0);
 }
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableJoinWithSelfJoinOperator() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName)"
     + " select p1.name as profileName"
     + " from testavro.PROFILE.`$table` as p1"
     + " join testavro.PROFILE.`$table` as p2"
     + " on p1.id = p2.id";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableJoinWithThetaCondition() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv"
     + " join testavro.PROFILE.`$table` as p"
     + " on p.id <> pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateStreamTableJoinWithAndLiteralCondition() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv"
     + " join testavro.PROFILE.`$table` as p"
     + " on p.id = pv.profileId and p.name = 'John'";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test (expected = SamzaException.class)
public void testTranslateJoinWithIncorrectRightJoin() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 1);
 String sql =
   "Insert into testavro.enrichedPageViewTopic(profileName, pageKey)"
     + " select p.name as profileName, pv.pageKey"
     + " from testavro.PAGEVIEW as pv"
     + " right join testavro.PROFILE.`$table` as p"
     + " on p.id = pv.profileId";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
}
origin: apache/samza

@Test
public void testTranslateGroupBy() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(configs, 10);
 String sql =
   "Insert into testavro.pageViewCountTopic(jobName, pageKey, `count`)"
     + " select 'SampleJob' as jobName, pv.pageKey, count(*) as `count`"
     + " from testavro.PAGEVIEW as pv"
     + " where pv.pageKey = 'job' or pv.pageKey = 'inbox'"
     + " group by (pv.pageKey)";
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, sql);
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
 OperatorSpecGraph specGraph = streamAppDesc.getOperatorSpecGraph();
 Assert.assertEquals(1, specGraph.getInputOperators().size());
 Assert.assertEquals(1, specGraph.getOutputStreams().size());
 assertTrue(specGraph.hasWindowOrJoins());
 Collection<OperatorSpec> operatorSpecs = specGraph.getAllOperatorSpecs();
}
origin: apache/samza

@Test
public void testTranslateComplex() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(10);
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT,
   "Insert into testavro.outputTopic(string_value) select Flatten(array_values) from testavro.COMPLEX1");
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl streamAppDesc = new StreamApplicationDescriptorImpl(streamApp -> { }, samzaConfig);
 QueryTranslator translator = new QueryTranslator(streamAppDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), streamAppDesc, 0);
 OperatorSpecGraph specGraph = streamAppDesc.getOperatorSpecGraph();
 StreamConfig streamConfig = new StreamConfig(samzaConfig);
 String inputStreamId = specGraph.getInputOperators().keySet().stream().findFirst().get();
 String inputSystem = streamConfig.getSystem(inputStreamId);
 String inputPhysicalName = streamConfig.getPhysicalName(inputStreamId);
 String outputStreamId = specGraph.getOutputStreams().keySet().stream().findFirst().get();
 String outputSystem = streamConfig.getSystem(outputStreamId);
 String outputPhysicalName = streamConfig.getPhysicalName(outputStreamId);
 Assert.assertEquals(1, specGraph.getOutputStreams().size());
 Assert.assertEquals("testavro", outputSystem);
 Assert.assertEquals("outputTopic", outputPhysicalName);
 Assert.assertEquals(1, specGraph.getInputOperators().size());
 Assert.assertEquals("testavro", inputSystem);
 Assert.assertEquals("COMPLEX1", inputPhysicalName);
}
origin: apache/samza

@Test
public void testTranslate() {
 Map<String, String> config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(10);
 config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT,
   "Insert into testavro.outputTopic(id) select MyTest(id) from testavro.level1.level2.SIMPLE1 as s where s.id = 10");
 Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
 List<String> sqlStmts = fetchSqlFromConfig(config);
 List<SamzaSqlQueryParser.QueryInfo> queryInfo = fetchQueryInfo(sqlStmts);
 SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSources).flatMap(Collection::stream)
     .collect(Collectors.toList()),
   queryInfo.stream().map(SamzaSqlQueryParser.QueryInfo::getSink).collect(Collectors.toList()));
 StreamApplicationDescriptorImpl appDesc = new StreamApplicationDescriptorImpl(streamApp -> { },samzaConfig);
 QueryTranslator translator = new QueryTranslator(appDesc, samzaSqlApplicationConfig);
 translator.translate(queryInfo.get(0), appDesc, 0);
 OperatorSpecGraph specGraph = appDesc.getOperatorSpecGraph();
 StreamConfig streamConfig = new StreamConfig(samzaConfig);
 String inputStreamId = specGraph.getInputOperators().keySet().stream().findFirst().get();
 String inputSystem = streamConfig.getSystem(inputStreamId);
 String inputPhysicalName = streamConfig.getPhysicalName(inputStreamId);
 String outputStreamId = specGraph.getOutputStreams().keySet().stream().findFirst().get();
 String outputSystem = streamConfig.getSystem(outputStreamId);
 String outputPhysicalName = streamConfig.getPhysicalName(outputStreamId);
 Assert.assertEquals(1, specGraph.getOutputStreams().size());
 Assert.assertEquals("testavro", outputSystem);
 Assert.assertEquals("outputTopic", outputPhysicalName);
 Assert.assertEquals(1, specGraph.getInputOperators().size());
 Assert.assertEquals("testavro", inputSystem);
 Assert.assertEquals("SIMPLE1", inputPhysicalName);
}
origin: apache/samza

  "Insert into testavro.outputTopic(string_value, id) select Flatten(a), id "
    + " from (select id, array_values a, string_value s from testavro.COMPLEX1)");
Config samzaConfig = SamzaSqlApplicationRunner.computeSamzaConfigs(true, new MapConfig(config));
org.apache.samza.sql.runnerSamzaSqlApplicationRunnercomputeSamzaConfigs

Popular methods of SamzaSqlApplicationRunner

  • run
  • waitForFinish
  • <init>
    NOTE: This constructor is called from ApplicationRunners through reflection. Please refrain from upd
  • kill
  • runAndWaitForFinish
  • status

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • JPanel (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Option (scala)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now