Skip to content

Commit

Permalink
Fix distinct operator for UUID
Browse files Browse the repository at this point in the history
Cherry-pick of  trinodb/trino#1180 by guyco33
Co-authored-by: Guy Cohen <[email protected]>
  • Loading branch information
abhibongale authored and tdcmeehan committed Oct 7, 2024
1 parent 832b071 commit 88c03ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static boolean isDistinctFrom(
if (left.isNull(leftPosition)) {
return false;
}
return left.compareTo(leftPosition, 0, UUID.getFixedSize(), right, rightPosition, 0, UUID.getFixedSize()) != 0;
return !UUID.equalTo(left, leftPosition, right, rightPosition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,14 @@ public void testMixedDistinctWithFilter()
"FROM (VALUES (1, 3), (2, 4), (2, 4), (4, 5)) t (x, y)",
"VALUES (BIGINT '0', CAST(NULL AS BIGINT))");
}

@Test
public void testUuidDistinct()
{
assertions.assertQuery(
"SELECT DISTINCT uuid_col " +
"FROM (VALUES (UUID'be0b0518-35a1-4d10-b7f1-1b61355fa741')," +
" (UUID'be0b0518-35a1-4d10-b7f1-1b61355fa741')) AS t (uuid_col)",
"VALUES UUID'be0b0518-35a1-4d10-b7f1-1b61355fa741'");
}
}

0 comments on commit 88c03ab

Please sign in to comment.