Skip to content

CALCITE-5647 Use mq.getRowCount(rel) instead of rel.estimateRowCount(mq)#3151

Closed
adamkennedy wants to merge 1 commit intoapache:mainfrom
adamkennedy:calcite-5647
Closed

CALCITE-5647 Use mq.getRowCount(rel) instead of rel.estimateRowCount(mq)#3151
adamkennedy wants to merge 1 commit intoapache:mainfrom
adamkennedy:calcite-5647

Conversation

@adamkennedy
Copy link
Contributor

This PR corrects a row count call to use the RelMetadataQuery instead of going directly to rel.estimateRowCount.

Using rel.estimateRowCount directly will behave incorrectly when using a cardinality estimator that is implemented entirely in a MetadataHandler class, as it will evade the metadata handler's implementation of getRowCount and fall through to the underlying default method for Values.

This corrects the problem by using mq.getRowCount instead of rel.estimateRowCount. In the default case this results in the same value but in the custom cardinality model case the expected handler is called.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@libenchao libenchao self-assigned this Apr 15, 2023
Copy link
Contributor

@chunweilei chunweilei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a test to show the difference?

@jduo
Copy link
Member

jduo commented Jan 17, 2024

Hi @adamkennedy, @libenchao , @chunweilei and others.
I'm continuing the work on this PR at #3632.

(That PR has the unit test and is rebased on main).

@mihaibudiu
Copy link
Contributor

Should this PR be closed?

@jduo
Copy link
Member

jduo commented Jan 17, 2024

Should this PR be closed?

Yes, please do.

@mihaibudiu
Copy link
Contributor

Closed in favor of #3632

@mihaibudiu mihaibudiu closed this Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

more-tests-needed Need more tests to make the patch complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants