Skip to content

Conversation

@thomasrebele
Copy link
Contributor

See HIVE-29424.

What changes were proposed in this pull request?

This PR adapts FilterSelectivityEstimator so that histogram statistics are used for range predicates with a cast.
I added many test cases to some cover corner cases. To get the ground truth, I executed queries with the predicates, see the resulting q.out file.

Why are the changes needed?

This PR allows the CBO planner to use histogram statistics for range predicates that contain a CAST around the input column.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Unit tests were added.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

Comment on lines +228 to +233
if (range == null)
return cast;
if (range.minValue == null || Double.isNaN(range.minValue.doubleValue()))
return cast;
if (range.maxValue == null || Double.isNaN(range.maxValue.doubleValue()))
return cast;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix the 'if' construct must use '{}'s checkstyle warnings when updating the commit.

Comment on lines +344 to +345
float[] boundaries = new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY };
boolean[] inclusive = new boolean[] { true, true };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix the '{' is followed by whitespace warnings when updating the PR.

useFieldWithValues("f_numeric", VALUES2, KLL2);
float total = VALUES2.length;

{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checkstyle warns about nested blocks, I'll refactor this when updating the PR.

@thomasrebele thomasrebele marked this pull request as ready for review February 4, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants