apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
11.84k stars 3.12k forks source link

[Bug] old planner can not rewrite BetweenPredicate in having #29798

Closed iwanttobepowerful closed 5 months ago

iwanttobepowerful commented 5 months ago

Search before asking

Version

master

What's Wrong?

create table  test(a DATE,b varchar(100),c varchar (100),d varchar(100),e int,f int)  
ENGINE=OLAP
DUPLICATE KEY( a )
COMMENT "OLAP"
DISTRIBUTED BY HASH( e ) BUCKETS  auto
PROPERTIES (
    "replication_num" = "1"
);

set experimental_enable_nereids_planner = false;

select t1.a,t1.b,t1.c,t1.f,t1.d,t1.e,stddev_pop(t1.d+t1.e) std from test t1 
group by t1.f,t1.d,t1.e,t1.a,t1.b,t1.c
having t1.b between 'aa' and 'bb';

ERROR 1105 (HY000): IllegalStateException, msg: java.lang.IllegalStateException: BetweenPredicate needs to be rewritten into a CompoundPredicate.

What You Expected?

can get result

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

iwanttobepowerful commented 5 months ago

@morningman hi, can you help fix this bug? Thx.

ihadoop commented 5 months ago

我试了一下最新版本的不报错。 image

iwanttobepowerful commented 5 months ago

我试了一下最新版本的不报错。 image

老优化器报错

Nitin-Kashyap commented 5 months ago

I can look into it!

issue seems to be because BetweenPredicate is pushed down to ScanNode. And the rewritten expression (BetweenPredicate to CompoundPredicate) even if done is not applied to pushdown predicates