Skip to content

[Feature] Add hamming_distance string function for Trino/Presto [fix repo] #60890

Open
zjoyjin wants to merge 3 commits intoapache:masterfrom
zjoyjin:feat/hamming-distance
Open

[Feature] Add hamming_distance string function for Trino/Presto [fix repo] #60890
zjoyjin wants to merge 3 commits intoapache:masterfrom
zjoyjin:feat/hamming-distance

Conversation

@zjoyjin
Copy link

@zjoyjin zjoyjin commented Feb 27, 2026

What problem does this PR solve?

Issue Number: subclass issue for #17176

Problem Summary:
Implemented hamming_distance(string, string) in vectorized BE string functions.
Registered the function in BE string function factory.
Added Nereids scalar function metadata (HammingDistance) and FE builtin registration.
Added FE constant-folding support for literal arguments.

Behavioral impact

Adds a new scalar string function:

  • hamming_distance(left, right)
  • Returns the number of differing character positions
  • Raises error when input strings have unequal length

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • [X ] Unit Test
    • [X ] Manual test (add detailed scripts or steps below)
    • select hamming_distance('karolin', 'kathrin');
    • select hamming_distance('1011101', '1001001');
    • select hamming_distance('abc', 'ab'); (expect error)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes. Adds new SQL function 'hamming_distance'.
  • Does this need documentation?

    • No.
    • Yes. (SQL function docs can be added in a follow-up PR if needed, but not sure if needed now)

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@zjoyjin zjoyjin requested a review from zclllyybb as a code owner February 27, 2026 13:24
@Thearas
Copy link
Contributor

Thearas commented Feb 27, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@zclllyybb zclllyybb self-assigned this Feb 27, 2026
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.

3 participants