apache / drill

Apache Drill is a distributed MPP query layer for self describing data
https://drill.apache.org/
Apache License 2.0
1.93k stars 979 forks source link

DRILL-8512: ReduceAndSimplifyFilterRule fails with NullPointerException #2944

Open rymarm opened 1 week ago

rymarm commented 1 week ago

DRILL-8512: ReduceAndSimplifyFilterRule fails with NullPointerException

Description

I'm not sure why the following issue wasn't before, but it's clear, why the issue appears at all - because we provide neither inputs RelNodes(we calling DrillOptiq.toDrill with null for the input, see code change) or RexBuilder along with RelDataType.

Testing

Tested with the query the issue was reproduced:

SELECT *
FROM
(
SELECT
(CASE WHEN (true) THEN 'qwe' ELSE null END) res1
FROM (VALUES(1)) test_tbl
) test
where res1 IN ('ab','dab','qw','qwe') 
rymarm commented 1 week ago

@jnturton I'm unsure whether the fix is correct because calcite is a black box to me, but I think I found the correct place where the change should be made.

I'll be glad if you advise me on how to cover the case with unit tests.

cgivre commented 1 week ago

@jnturton I'm unsure whether the fix is correct because calcite is a black box to me, but I think I found the correct place where the change should be made.

I'll be glad if you advise me on how to cover the case with unit tests.

You're not the only one to whom Calcite is a black box... :-)

rymarm commented 1 week ago

I saw the failing tests. I need to find another solution to solve the issue...