Hi,

I've been using the RelBuilder again to query jdbc sources, but find that
no matter what the query, the joins/projects/filters are just not pushed
down to the database. I'm only querying against a single table in a single
database (postgres in this case).

The plan output always shows LogicalProject, LogicalFilter, LogicalJoin.
Should the Logical here be Jdbc if things were working correctly?

Here's how I'm constructing the builder, perhaps I'm missing a jdbc option
here?

Class.forName("org.apache.calcite.jdbc.Driver");
Connection connection =
        DriverManager.getConnection("jdbc:calcite:");
CalciteConnection calciteConnection =
        connection.unwrap(CalciteConnection.class);
Class.forName("org.postgresql.Driver");

BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl("jdbc:postgresql://localhost/my_test_db");
dataSource.setUsername("dev");
dataSource.setPassword("dev");
dataSource.setDefaultCatalog("public");
JdbcSchema jdbcSchema =
JdbcSchema.create(calciteConnection.getRootSchema(), "source1", dataSource,
null, "public");

// add schema to connection
SchemaPlus rootSchema = calciteConnection.getRootSchema();
rootSchema.add("source1", jdbcSchema);

FrameworkConfig config = Frameworks.newConfigBuilder()
        .defaultSchema(rootSchema)
        .parserConfig(SqlParser.Config.DEFAULT)
        .build();

RelBuilder builder = RelBuilder.create(config);

// make the builder query:
builder.scan("source1", "some_table")
.project(builder.field(1, 0, "property_id"))
.filter(builder.call(SqlStdOperatorTable.EQUALS, builder.field(1, 0,
"property_id"), builder.literal(5)))
.build()

// results in the following sql:
// SELECT * FROM some_table

Reply via email to