/** A trojan-horse method, subject to change without notice. */ @VisibleForTesting public static CalciteConnection connect(CalciteSchema schema, JavaTypeFactory typeFactory) { return DRIVER.connect(schema, typeFactory); }
/** A trojan-horse method, subject to change without notice. */ @VisibleForTesting public static CalciteConnection connect(CalciteSchema schema, JavaTypeFactory typeFactory) { return DRIVER.connect(schema, typeFactory); }
/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-281">[CALCITE-1919] * NPE when target in ReflectiveSchema belongs to the unnamed package</a>. */ @Test public void testReflectiveSchemaInUnnamedPackage() throws Exception { final Driver driver = new Driver(); try (CalciteConnection connection = (CalciteConnection) driver.connect("jdbc:calcite:", new Properties())) { SchemaPlus rootSchema = connection.getRootSchema(); final Class<?> c = Class.forName("RootHr"); final Object o = c.getDeclaredConstructor().newInstance(); rootSchema.add("hr", new ReflectiveSchema(o)); connection.setSchema("hr"); final Statement statement = connection.createStatement(); final String sql = "select * from \"emps\""; final ResultSet resultSet = statement.executeQuery(sql); final String expected = "empid=100; name=Bill\n" + "empid=200; name=Eric\n" + "empid=150; name=Sebastian\n"; assertThat(CalciteAssert.toString(resultSet), is(expected)); } }
/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-281">[CALCITE-1919] * NPE when target in ReflectiveSchema belongs to the unnamed package</a>. */ @Test public void testReflectiveSchemaInUnnamedPackage() throws Exception { final Driver driver = new Driver(); try (CalciteConnection connection = (CalciteConnection) driver.connect("jdbc:calcite:", new Properties())) { SchemaPlus rootSchema = connection.getRootSchema(); final Class<?> c = Class.forName("RootHr"); final Object o = c.getDeclaredConstructor().newInstance(); rootSchema.add("hr", new ReflectiveSchema(o)); connection.setSchema("hr"); final Statement statement = connection.createStatement(); final String sql = "select * from \"emps\""; final ResultSet resultSet = statement.executeQuery(sql); final String expected = "empid=100; name=Bill\n" + "empid=200; name=Eric\n" + "empid=150; name=Sebastian\n"; assertThat(CalciteAssert.toString(resultSet), is(expected)); } }
final Driver driver = new Driver(); CalciteConnection connection = (CalciteConnection) driver.connect("jdbc:calcite:", new Properties()); SchemaPlus rootSchema = connection.getRootSchema(); rootSchema.add("sale", new ReflectiveSchema(new Smalls.WideSaleSchema()));
final Driver driver = new Driver(); CalciteConnection connection = (CalciteConnection) driver.connect("jdbc:calcite:", new Properties()); SchemaPlus rootSchema = connection.getRootSchema(); rootSchema.add("sale", new ReflectiveSchema(new Smalls.WideSaleSchema()));
driver.connect("jdbc:calcite:", new Properties()); SchemaPlus rootSchema = connection.getRootSchema(); rootSchema.add("hr", new ReflectiveSchema(new HrSchema()));
driver.connect("jdbc:calcite:", new Properties()); SchemaPlus rootSchema = connection.getRootSchema(); rootSchema.add("hr", new ReflectiveSchema(new HrSchema()));