1

I wrote a calcite adapter and now I want to write some tests to verify my physical plan. I want to use CalciteAssert to do that like in Cassandra Adapter, but outside the Calcite Project how can I do that?

  @Test public void testFilter() {
    CalciteAssert.that()
        .with(TWISSANDRA)
        .query("select * from \"userline\" where \"username\"='!PUBLIC!'")
        .limit(1)
        .returns("username=!PUBLIC!; time=e8754000-80b8-1fe9-8e73-e3698c967ddd; "
            + "tweet_id=f3c329de-d05b-11e5-b58b-90e2ba530b12\n")
        .explainContains("PLAN=CassandraToEnumerableConverter\n"
           + "  CassandraFilter(condition=[=($0, '!PUBLIC!')])\n"
           + "    CassandraTableScan(table=[[twissandra, userline]]");
  }

1 Answers1

1

There has been talk of changing this in the future, but currently you can add the test code as a dependency to your project. In Maven, this would look something like this:

<dependency>
    <groupId>org.apache.calcite</groupId>
    <artifactId>calcite-core</artifactId>
    <version>1.20.0</version>
    <classifier>tests</classifier>
    <type>test-jar</type>
</dependency>
Michael Mior
  • 28,107
  • 9
  • 89
  • 113
  • I've also done exactly this, to use the CalciteAssert utilities to test a custom adapter. It works great – Mzzzzzz Mar 14 '20 at 16:26