Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor](Nereids) New expression extractor for partitions pruning (a…
…pache#36326) An exception throw in TryEliminateUninterestedPredicates, for this case CREATE TABLE `tbltest` ( `id` INT NULL, `col2` VARCHAR(255) NULL, `col3` VARCHAR(255) NULL, `dt` DATE NULL ) ENGINE=OLAP DUPLICATE KEY(`id`, `col2`) PARTITION BY RANGE(`dt`) (PARTITION p20240617 VALUES [('2024-06-17'), ('2024-06-18'))) DISTRIBUTED BY HASH(`id`) BUCKETS 10 PROPERTIES ( "replication_allocation" = "tag.location.default: 1" ); select * from tbltest where case when col2 = 'xxx' and col3='yyy' then false -- note this is not about partition column when col2 in ('xxx') then false when col2 like 'xxx%' then false else true end The CaseWhen require children should be WhenClause, TryEliminateUninterestedPredicates maybe rewrite the WhenClause to true/false predicate, and cause this exception: ERROR 1105 (HY000): errCode = 2, detailMessage = The children format needs to be [WhenClause+, DefaultValue?] Original extractor(TryEliminateUninterestedPredicates.java) caused some errors while try to derive the expressions which can be used for pruning partitions. I tried to write a new extractor(and with unit tests) for pruning partitions, it is more simple and reliable (I think). The theory of extractor is pretty simple: A:Sort the expression in two kinds: 1. evaluable-expression (let's mark it as E). Expressions that can be evaluated in the partition pruning stage. In the other word: not contains non-partition slots or deterministic expression. 2. un-evaluable-expression (let's mark it as UE). Expressions that can NOT be evaluated in the partition pruning stage. In the other word: contains non-partition slots or deterministic expression. B: Travel the predicate, only point on AND and OR operator, following the rule: (E and UE) -> (E and TRUE) -> E (UE and UE) -> TRUE (E and E) -> (E and E) (E or UE) -> TRUE (UE or UE) -> TRUE (E or E) -> (E or E)
- Loading branch information