Keep in mind that for general queries, this is a very non-trivial problem
and an active area of research. However, doing this for the case of a
filter applied to a single table should be much more straightforward. One
way to do this would be to create your own subclass of EnumerableFilter
with its own convention and then choose your rules carefully (along with a
copy of EnumerableFilterRule for your new convention).

You would then implement whatever logging logic you need inside
EnumerableFilter. It's still a nontrivial amount of code, but definitely
doable. Others might have suggestions on an easier way to implement this.

--
Michael Mior
mm...@apache.org


On Tue, Sep 26, 2023 at 2:07 PM Luis Brassara <luis.brass...@gmail.com>
wrote:

> Hi, all.
>
> I'm using Apache Calcite with SQL.
>
> I'm trying to execute an SQL query like
>
> SELECT * FROM table WHERE some_field = 1 AND other_field = 5)
>
> where table is:
>
>        some_field | other field
>        ------------------------
> row 1:      1      |     2
> row 2:      1      |     3
>
>
> This query will return empty results.
>
> I want to tell the user why the query returned empty results, row by row.
> Then, I want to be able to access the query plan and transverse it to the
> node that produced the empty results (other_field = 5) and I want to have
> in context the current value of other_field (2) so I can print messages
> like:
>
> Row 1 failed because `other_field` was `2` and `5` was expected
> Row 2 failed because `other_field` was `3` and `5` was expected
>
> I'm not sure which Calcite classes should I use to achieve that, any advice
> / example?
>
> Thanks in advance!
>

Reply via email to