BeamSqlEnv { public static BeamSqlEnvBuilder builder(TableProvider tableProvider) { return new BeamSqlEnvBuilder(tableProvider); } private  BeamSqlEnv(JdbcConnection connection, QueryPlanner planner); static BeamSqlEnvBuilder builder(TableProvider tableProvider); static BeamSqlEnv readOnly(String tableType, Map<String, BeamSqlTable> tables); static BeamSqlEnv withTableProvider(TableProvider tableProvider); static BeamSqlEnv inMemory(TableProvider... tableProviders); BeamRelNode parseQuery(String query); BeamRelNode parseQuery(String query, QueryParameters queryParameters); boolean isDdl(String sqlStatement); void executeDdl(String sqlStatement); CalcitePrepare.Context getContext(); Map<String, String> getPipelineOptions(); String explain(String sqlString);  }
@Test public void testCreateExternalTableInNestedTableProvider() throws Exception { TestTableProvider root = new TestTableProvider(); TestTableProvider nested = new TestTableProvider(); TestTableProvider anotherOne = new TestTableProvider(); BeamSqlEnv env = BeamSqlEnv.builder(root) .addSchema("nested", nested) .addSchema("anotherOne", anotherOne) .setPipelineOptions(PipelineOptionsFactory.create()) .build(); Connection connection = env.connection; connection.createStatement().execute("CREATE EXTERNAL TABLE nested.person (id INT) TYPE test"); connection.createStatement().execute("INSERT INTO nested.person(id) VALUES (1), (2), (6)"); ResultSet rs = connection.createStatement().executeQuery("SELECT SUM(id) FROM nested.person"); rs.next(); assertEquals(9, rs.getInt(1)); }
@Test public void testPlannerClassNotFound() { exceptions.expect(RuntimeException.class); exceptions.expectCause(hasMessage(containsString("org.test.ClassNotFound"))); TestTableProvider root = new TestTableProvider(); BeamSqlEnv.builder(root) .setQueryPlannerClassName("org.test.ClassNotFound") .setPipelineOptions(PipelineOptionsFactory.create()) .build(); }