asolimando commented on code in PR #4734:
URL: https://github.com/apache/calcite/pull/4734#discussion_r2677337246
##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java:
##########
@@ -191,9 +191,10 @@ public Double getRowCount(Calc rel, RelMetadataQuery mq) {
return sampleRate * inputRowCount;
}
- // Covers Converter, Interpreter
+ // Covers Converter, Interpreter, and custom SingleRel subclasses
+ // Delegates to estimateRowCount() to allow subclasses to provide custom
estimates
public @Nullable Double getRowCount(SingleRel rel, RelMetadataQuery mq) {
- return mq.getRowCount(rel.getInput());
+ return rel.estimateRowCount(mq);
Review Comment:
https://github.com/apache/calcite/blob/506950a3ebd4807b36901bededc64f7c60497712/core/src/main/java/org/apache/calcite/rel/SingleRel.java#L66-L69
The default implementation of `SingleRel.estimateRowCount(mq)` is just
`mq.getRowCount(rel.getInput())`, so you have:
- before: `RelMdRowCount.getRowCount(SingleRel rel, RelMetadataQuery mq)`
-> `mq.getRowCount(rel.getInput())`
- after: `RelMdRowCount.getRowCount(SingleRel rel, RelMetadataQuery mq)` ->
`SingleRel.estimateRowCount(mq)` -> `mq.getRowCount(rel.getInput())`
So this is backward compatible, you just do an extra hop that by default
changes nothing w.r.t. before, but it allows subclasses to override behavior,
if needed.
Thanks for checking so quickly, Mihai!
--
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]