spaces-X opened a new issue #3887: URL: https://github.com/apache/incubator-doris/issues/3887
Create table: ``` create table t2 (dt int, id int, pv int sum) aggregate key(`dt`, `id`) partition by range (dt) ( partition p20200610 values less than ("20200610"), partition p20200611 values less than ("20200611")) distributed by hash(`id`) buckets 1 properties("replication_num"="1"); ``` Load Data: ``` insert into t2 (dt, id, pv) values (20200609, 1, 10), (20200609, 2, 20); insert into t2 (dt, id, pv) values (20200610, 1, 10), (20200610, 2, 20); ``` Query1: ``` explain select * from t2 where dt=20200609; | 0:OlapScanNode | | TABLE: t2 | | PREAGGREGATION: OFF. Reason: No AggregateInfo | | PREDICATES: `dt` = 20200609 | | partitions=1/2 only one partition ``` Query2: ``` explain select * from t2 where dt='20200609'; | 0:OlapScanNode | | TABLE: t2 | | PREAGGREGATION: OFF. Reason: No AggregateInfo | | PREDICATES: `dt` = 2.0200609E7 | | partitions=2/2 scan all partitions ``` In query2, the compatible type of `whereclause`(`BinaryPredicate`) will be `Type.DOUBLE` and the `SlotRef` of 'dt' will be casted to CastExpr with double type, which cause the `canHashPartition` function return false. In this situation, we couldn't create `createPartitionFilter` successfully and scan all partitions. CastExpr#canHashPartition ``` public boolean canHashPartition() { if (type.isFixedPointType() && getChild(0).getType().isFixedPointType()) { return true; } if (type.isDateType() && getChild(0).getType().isDateType()) { return true; } return false; } ``` BinaryPredicate#getSlotBinding ``` public Expr getSlotBinding(SlotId id) { SlotRef slotRef = null; // check left operand if (getChild(0) instanceof SlotRef) { slotRef = (SlotRef) getChild(0); } else if (getChild(0) instanceof CastExpr && getChild(0).getChild(0) instanceof SlotRef) { if (((CastExpr) getChild(0)).canHashPartition()) { slotRef = (SlotRef) getChild(0).getChild(0); } } ... return null } ``` Any advices for improving this situation? By the way, why should we use the `canHashPartition` condition in `getSlotBinding`? Could we safely remove `canHashPartition` in `getSlotBinding`? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org