Skip to content

refactor: String column like % can rewrite to true #18263

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 1 commit into from
Jun 30, 2025

Conversation

TCeason
Copy link
Collaborator

@TCeason TCeason commented Jun 27, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

In Snowflake :

explain select * from t where id=1 or c like '%' the like expr will rewrite to ((OCTET_LENGTH(T.C)) >= 0)

However, I think that if the column type is string/variant and not null, we can return true directly.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@TCeason TCeason marked this pull request as draft June 27, 2025 02:57
@TCeason TCeason changed the title optimize: String/Variant column like % can rewrite to true refactor: String/Variant column like % can rewrite to true Jun 27, 2025
@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Jun 27, 2025
@TCeason TCeason force-pushed the like_% branch 2 times, most recently from 574c677 to e5ad211 Compare June 27, 2025 05:52
@TCeason TCeason marked this pull request as ready for review June 27, 2025 08:28
@TCeason TCeason requested a review from sundy-li June 27, 2025 08:28
insert into t1 values('c',parse_json('[1,2,3,["a","b","c"],{"k":"v"}]'), 1),('c1',parse_json('[1,2,3,["a","b","c"],{"k":"v1"}]'), 2)

query T
explain select c from t1 where c like '%'
Copy link
Member

Choose a reason for hiding this comment

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

why not make it into domain cal for function like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, that's exactly the case. Implementing a function is somewhat superfluous. It is possible to directly return a FunctionDomain::Domain(ALL_TRUE_DOMAIN)

@TCeason TCeason changed the title refactor: String/Variant column like % can rewrite to true refactor: String column like % can rewrite to true Jun 27, 2025
@TCeason TCeason requested a review from sundy-li June 27, 2025 11:51
@BohuTANG BohuTANG merged commit 904b33a into databendlabs:main Jun 30, 2025
89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-refactor this PR changes the code base without new features or bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants