测试我自己的适配器时如何使用 CalciteAssert?

How to use CalciteAssert when test my own adapter?

我写了一个方解石适配器,现在我想写一些测试来验证我的物理计划。我想像在 Cassandra Adapter 中一样使用 CalciteAssert 来执行此操作,但在 Calcite Project 之外我该怎么做?

  @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=[=([=10=], '!PUBLIC!')])\n"
           + "    CassandraTableScan(table=[[twissandra, userline]]");
  }

有人说将来会改变这个,但目前您可以将测试代码作为依赖项添加到您的项目中。在 Maven 中,这看起来像这样:

<dependency>
    <groupId>org.apache.calcite</groupId>
    <artifactId>calcite-core</artifactId>
    <version>1.20.0</version>
    <classifier>tests</classifier>
    <type>test-jar</type>
</dependency>