Hello,

I’m trying to implement COALESCE for elastic adapter and would like to know
what is recommended approach to identify original function (after possible
rewrites).

Let me give an example.

Currently calcite converts COALESCE(attr, 'foo') into CASE(IS NOT
NULL(attr), attr, 'foo'). So in adapter I have to traverse RexCall and
check kind=CASE and operators[0] == IS NOT NULL and operators[1] ==
INPUT_REF and operators[2] is literal to properly convert this call into
native elastic operation. Elastic has something similar
<https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html#_missing_value_2>
to
coalesce (missing value) but not a generic case statement.

What if tomorrow calcite decides to keep coalesce as is or rewrite to CASE(IS
NULL(attr),'foo', attr) ? It seems to me that trying all possible
combinations is a wrong thing to do (correct me if I’m wrong).

How can I make this logic future-proof ?

Thanks,

Andrei.

Reply via email to