Skip to content

PHOENIX-7610 Using CAST() on pk columns always result in full table scan #2150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 18, 2025

Conversation

virajjasani
Copy link
Contributor

@virajjasani virajjasani commented May 13, 2025

Jira: PHOENIX-7610

For the range scan or point lookup on the single row, it is required to provide either full pk columns with equal comparison (point lookup) or prefix pk columns with equal comparison operator (range scan).

However, when we use SQL CAST() function on pk columns to convert the type of the given column into another data type, the plan generated by where optimizer always performs full table scan instead of range scan or point lookup.

Copy link
Contributor

@kadirozde kadirozde left a comment

Choose a reason for hiding this comment

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

+1, Thanks!

@Override
public boolean isStateless() {
// It is important to associate the stateless-ness of the CoerceExpression
// child with the CoerceExpression. Without this, ComparisonExpression and
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor update on your comment as follows. "Without this, ComparisonExpression and KeyExpressionVisitor will not be evaluated on the client side, and thus WhereOptimizer always select ..."

@virajjasani virajjasani merged commit 9cb4883 into apache:master May 18, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants