Skip to content

[CALCITE-7727] Comparing UUID <> '' always returns FALSE - #5191

Merged
mihaibudiu merged 1 commit into
apache:mainfrom
mihaibudiu:issue7727
Aug 19, 2026
Merged

[CALCITE-7727] Comparing UUID <> '' always returns FALSE#5191
mihaibudiu merged 1 commit into
apache:mainfrom
mihaibudiu:issue7727

Conversation

@mihaibudiu

@mihaibudiu mihaibudiu commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Jira Link

CALCITE-7727

Changes Proposed

I had mistakenly implemented type coercion between UUID and CHAR/BINARY by converting UUID to CHAR/BINARY.
Postgres does the opposite, and I think it's the right choice. The previous choice leads to the surprising behavior described by the current issue. The new behavior also parallels other type coercions, e.g. comparisons between INT and CHAR, which cast to INT.

The documentation was actually silent about this behavior, so we can claim it was undocumented. I have added this change of semantics to the release notes.

I have also made the cast from string to UUID behave closer to Postgres.

@rubenada rubenada left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

nit: I think there's another occurrence of UUID.fromString in RelWriterTest that for consistency should be replaced with the new SqlFunctions.stringToUuid

@xuzifu666 xuzifu666 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, left some minor comments.

Long.parseUnsignedLong(digits.substring(16), 16));
}

private static boolean isHexDigit(char c) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems to duplicate the SqlParserUtil.isHexDigit method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will remove the duplicate

* 123e4567-e89b-12d3-a456-42665544000 31 digits
* </pre></blockquote>
*/
public static UUID stringToUuid(String s) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The handling of blank string does not appear to be clearly defined; it needs to be consistent with PostgreSQL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will add a test for this

@mihaibudiu

Copy link
Copy Markdown
Contributor Author

LGTM

nit: I think there's another occurrence of UUID.fromString in RelWriterTest that for consistency should be replaced with the new SqlFunctions.stringToUuid

I will change this

@mihaibudiu

Copy link
Copy Markdown
Contributor Author

Since this is already approved, I will push an amended commit which performs all three suggested improvements and I will merge once CI passes. Thank you for the feedback!

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Aug 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@mihaibudiu
mihaibudiu merged commit 52f8d60 into apache:main Aug 19, 2026
22 of 37 checks passed
@mihaibudiu
mihaibudiu deleted the issue7727 branch August 19, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants