nsivabalan opened a new pull request, #12575:
URL: https://github.com/apache/hudi/pull/12575
### Change Logs
- As of now, we lookup in col stats for all filter expressions. This patch
checks for any non indexed cols and avoids col stats based pruning. The files
from pruned files are used as candidate files if any non indexed cols are
detected. If not, pruning happens based on col stats index in MDT and candidate
files are deduced. We have also optimized the AND clause. If we have a
`leftExpr AND rightExpr`, where leftExpr has non indexed cols, while rightExpr
has all indexed cols, we can still afford to prune files based on col stats
index. Only if both leftExpr and rightExpr has non indexex cols, we can avoid
looking up in col stats index. Incase of 'Or' clause, we can't do much, but
have to resort to bypass col lookup completely.
lets walk through an example to understand this in detail
c1 = 619sdc or c2 = 100 and c3 = 200
Say this is the filter expression in the query issued.
case 1:
when all 3 cols are indexed w/ col stats:
expected col stats lookup expression is `(((('c1_minValue <= 619sdc) AND
('c1_maxValue >= 619sdc)) AND (('c2_minValue <= 100) AND ('c2_maxValue >=
100))) OR (('c3_minValue <= 200) AND ('c3_maxValue >= 200)))`
i.e. all 3 cols will be lookedup.
case 2:
only c1 and c2 are indexed for filter "c1 = 619sdc or c2 = 100 and c3 = 200":
since left of AND exp is indexed, we can ignore c3 which is not indexed
(rigth expr of AND).
we translate to
```
((('c1_minValue <= 619sdc) AND ('c1_maxValue >= 619sdc)) OR (('c2_minValue
<= 100) AND ('c2_maxValue >= 100)))
```
and lookup in col stats translated df.
case 3:
only c1 and c3 are indexed for filter "c1 = 619sdc or c2 = 100 and c3 = 200":
Among c1 and c2, c2 is not indexed. So, left Expr of (c1 = 619sdc or c2 =
100) is deemed as not indexed. But the right expr of 'c3 = 200' is indexed. and
so, we translate this to
```
(('c3_minValue <= 200) AND ('c3_maxValue >= 200))
```
and lookup in col stats translated df.
case 4:
only c2 and c3 are indexed for filter "c1 = 619sdc or c2 = 100 and c3 = 200":
Same as case 3
So, we translate it to
```
(('c3_minValue <= 200) AND ('c3_maxValue >= 200))
```
and lookup in col stats translated df.
case 5:
only c2 is indexed for filter "c1 = 619sdc or c2 = 100 and c3 = 200":
Since either of Or clause is not indexed, we have to bypass looking up in
col stats.
case 6:
only c3 is indexed for filter "c1 = 619sdc or c2 = 100 and c3 = 200":
Since either of Or clause is not indexed, we have to bypass looking up in
col stats.
case 7:
only c1 is indexed for filter "c1 = 619sdc or c2 = 100 and c3 = 200":
Since either of Or clause is not indexed, we have to bypass looking up in
col stats.
case 8:
only c2 is indexed for filter "c1 = 619sdc or c2 = 100 and c3 = 200":
Since either of Or clause is not indexed, we have to bypass looking up in
col stats.
Whenever we deem as col stats should not be looked up, we return the files
w/o pruning from the col stats lookup step.
### Impact
Optimized lookup in col stats.
### Risk level (write none, low medium or high below)
medium
### Documentation Update
_Describe any necessary documentation update if there is any new feature,
config, or user-facing change. If not, put "none"._
- _The config description must be updated if new configs are added or the
default value of the configs are changed_
- _Any new feature or user-facing change requires updating the Hudi website.
Please create a Jira ticket, attach the
ticket number here and follow the
[instruction](https://hudi.apache.org/contribute/developer-setup#website) to
make
changes to the website._
### Contributor's checklist
- [ ] Read through [contributor's
guide](https://hudi.apache.org/contribute/how-to-contribute)
- [ ] Change Logs and Impact were stated clearly
- [ ] Adequate tests were added if applicable
- [ ] CI passed
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]