@Override protected void init(final ProcessorInitializationContext context) { try { DriverManager.registerDriver(new org.apache.calcite.jdbc.Driver()); } catch (final SQLException e) { throw new ProcessException("Failed to load Calcite JDBC Driver", e); } final List<PropertyDescriptor> properties = new ArrayList<>(); properties.add(RECORD_READER_FACTORY); properties.add(RECORD_WRITER_FACTORY); properties.add(INCLUDE_ZERO_RECORD_FLOWFILES); properties.add(CACHE_SCHEMA); this.properties = Collections.unmodifiableList(properties); relationships.add(REL_FAILURE); relationships.add(REL_ORIGINAL); }
/** 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)); } }
/** A trojan-horse method, subject to change without notice. */ @VisibleForTesting public static CalciteConnection connect(CalciteSchema schema, JavaTypeFactory typeFactory) { return DRIVER.connect(schema, typeFactory); }
public Driver() { super(); this.prepareFactory = createPrepareFactory(); }
/** 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)); } }
/** A trojan-horse method, subject to change without notice. */ @VisibleForTesting public static CalciteConnection connect(CalciteSchema schema, JavaTypeFactory typeFactory) { return DRIVER.connect(schema, typeFactory); }
public Driver() { super(); this.prepareFactory = createPrepareFactory(); }
@Override protected void init(final ProcessorInitializationContext context) { try { DriverManager.registerDriver(new org.apache.calcite.jdbc.Driver()); } catch (final SQLException e) { throw new ProcessException("Failed to load Calcite JDBC Driver", e); } final List<PropertyDescriptor> properties = new ArrayList<>(); properties.add(RECORD_READER_FACTORY); properties.add(RECORD_WRITER_FACTORY); properties.add(INCLUDE_ZERO_RECORD_FLOWFILES); properties.add(CACHE_SCHEMA); this.properties = Collections.unmodifiableList(properties); relationships.add(REL_FAILURE); relationships.add(REL_ORIGINAL); }