Skip to content

Conversation

@singh1203
Copy link
Contributor

Fixes: #56

Rationale for this change

Many databases, including PostgreSQL, do not accept null characters (\x00) in strings. This PR introduces arrayApproxEqualString & arrayApproxEqualLargeString, functions that enables approximate equality comparison for string arrays while ignoring trailing null characters. This helps improve consistency with database behavior and aligns with existing arrayApproxEqualFloat16.

What changes are included in this PR?

  • Added arrayApproxEqualString:
    • Compares two string arrays for approximate equality.
    • Ignores trailing null characters (\x00).
  • Added unit tests in compare_test.go to verify correctness.

Are these changes tested?

Yes, unit tests have been added to validate:

  • Identical strings return true.
  • Strings differing only in trailing null characters return true.
  • Completely different strings return false.

Are there any user-facing changes?

No

@singh1203 singh1203 requested a review from zeroshade as a code owner February 19, 2025 10:33
Copy link
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

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

should also add the same for StringView too please

@singh1203
Copy link
Contributor Author

should also add the same for StringView too please

Added!

@singh1203 singh1203 requested a review from zeroshade February 20, 2025 09:30
@singh1203
Copy link
Contributor Author

@zeroshade I think we are GTG here.
Thank you.

@zeroshade zeroshade merged commit 7ef4d1e into apache:main Feb 21, 2025
23 checks passed
@singh1203 singh1203 deleted the ApproxEqStr branch February 25, 2025 06:53
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.

ApproxEqual for strings

2 participants