Apache Calcite get started example. Enables SQL over in-memory json objects stored in java.util.Map.
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<version>1.23.0</version>
</dependency>
Class.forName("org.apache.calcite.jdbc.Driver");
Properties info = new Properties();
info.setProperty("lex", "JAVA");
Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
SchemaPlus rootSchema = calciteConnection.getRootSchema();
Schema schema = new CustomSchema();
rootSchema.add("hr", schema);
Statement statement = calciteConnection.createStatement();
ResultSet rs = statement.executeQuery("select * from hr.employees as e where e.age >= 30");
while (rs.next()) {
long id = rs.getLong("id");
String name = rs.getString("name");
int age = rs.getInt("age");
System.out.println("id: " + id + "; name: " + name + "; age: " + age);
}
rs.close();
statement.close();
connection.close();
Thank you so much for this!
You missed adding this file.