You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Zain Humayun <zh...@yahoo-inc.com.INVALID> on 2017/06/08 17:44:26 UTC

Test that two SQL queries produce the same result

Hi,
I'm wondering what the best way to test that two queries produce the same final result. As far as I can see, CalciteAssert.AssertQuery doesn't contain such functionality. 
Zain.

Re: Test that two SQL queries produce the same result

Posted by Zain Humayun <zh...@yahoo-inc.com.INVALID>.
Thanks! I'll take a look into implementing that.

On Thursday, June 8, 2017, 11:00:00 AM PDT, Julian Hyde <jh...@apache.org> wrote:

Oh, and add a flag to CalciteAssert.ResultCollector() saying whether
the results have to be in the same order.

On Thu, Jun 8, 2017 at 10:59 AM, Julian Hyde <jh...@apache.org> wrote:
> Maybe something like this. In your test case:
>
>  @Test public void testMyStatements() {
>    final String sql1 = "...",
>      sql2 = "...";
>    final CalciteAssert.ResultCollector c = new CalciteAssert.ResultCollector();
>    sql(sql1).collect(c);
>    sql(sql2).returns(c.checker());
>  }
>
> In CalciteAssert:
>
>  public static class ResultCollector {
>      ...
>
>      public Function<ResultSet, Void> checker() {
>        ...
>      }
>  }
>
> In CalciteAssert.AssertQuery:
>
>  public AssertQuery collect(ResultCollector c) {
>      ...
>    return this;
>    }
>
> Julian
>
> On Thu, Jun 8, 2017 at 10:44 AM, Zain Humayun
> <zh...@yahoo-inc.com.invalid> wrote:
>> Hi,
>> I'm wondering what the best way to test that two queries produce the same final result. As far as I can see, CalciteAssert.AssertQuery doesn't contain such functionality.
>> Zain.

Re: Test that two SQL queries produce the same result

Posted by Julian Hyde <jh...@apache.org>.
Oh, and add a flag to CalciteAssert.ResultCollector() saying whether
the results have to be in the same order.

On Thu, Jun 8, 2017 at 10:59 AM, Julian Hyde <jh...@apache.org> wrote:
> Maybe something like this. In your test case:
>
>   @Test public void testMyStatements() {
>     final String sql1 = "...",
>       sql2 = "...";
>     final CalciteAssert.ResultCollector c = new CalciteAssert.ResultCollector();
>     sql(sql1).collect(c);
>     sql(sql2).returns(c.checker());
>   }
>
> In CalciteAssert:
>
>   public static class ResultCollector {
>      ...
>
>      public Function<ResultSet, Void> checker() {
>         ...
>      }
>   }
>
> In CalciteAssert.AssertQuery:
>
>   public AssertQuery collect(ResultCollector c) {
>      ...
>     return this;
>    }
>
> Julian
>
> On Thu, Jun 8, 2017 at 10:44 AM, Zain Humayun
> <zh...@yahoo-inc.com.invalid> wrote:
>> Hi,
>> I'm wondering what the best way to test that two queries produce the same final result. As far as I can see, CalciteAssert.AssertQuery doesn't contain such functionality.
>> Zain.

Re: Test that two SQL queries produce the same result

Posted by Julian Hyde <jh...@apache.org>.
Maybe something like this. In your test case:

  @Test public void testMyStatements() {
    final String sql1 = "...",
      sql2 = "...";
    final CalciteAssert.ResultCollector c = new CalciteAssert.ResultCollector();
    sql(sql1).collect(c);
    sql(sql2).returns(c.checker());
  }

In CalciteAssert:

  public static class ResultCollector {
     ...

     public Function<ResultSet, Void> checker() {
        ...
     }
  }

In CalciteAssert.AssertQuery:

  public AssertQuery collect(ResultCollector c) {
     ...
    return this;
   }

Julian

On Thu, Jun 8, 2017 at 10:44 AM, Zain Humayun
<zh...@yahoo-inc.com.invalid> wrote:
> Hi,
> I'm wondering what the best way to test that two queries produce the same final result. As far as I can see, CalciteAssert.AssertQuery doesn't contain such functionality.
> Zain.