Skip to content

Commit 88c03ab

Browse files
abhibongaleguyco33
authored andcommitted
Fix distinct operator for UUID
Cherry-pick of trinodb/trino#1180 by guyco33 Co-authored-by: Guy Cohen <guyco33@gmail.com>
1 parent 832b071 commit 88c03ab

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

presto-main/src/main/java/com/facebook/presto/type/UuidOperators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public static boolean isDistinctFrom(
199199
if (left.isNull(leftPosition)) {
200200
return false;
201201
}
202-
return left.compareTo(leftPosition, 0, UUID.getFixedSize(), right, rightPosition, 0, UUID.getFixedSize()) != 0;
202+
return !UUID.equalTo(left, leftPosition, right, rightPosition);
203203
}
204204
}
205205

presto-main/src/test/java/com/facebook/presto/sql/query/TestDistinctAggregations.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,14 @@ public void testMixedDistinctWithFilter()
272272
"FROM (VALUES (1, 3), (2, 4), (2, 4), (4, 5)) t (x, y)",
273273
"VALUES (BIGINT '0', CAST(NULL AS BIGINT))");
274274
}
275+
276+
@Test
277+
public void testUuidDistinct()
278+
{
279+
assertions.assertQuery(
280+
"SELECT DISTINCT uuid_col " +
281+
"FROM (VALUES (UUID'be0b0518-35a1-4d10-b7f1-1b61355fa741')," +
282+
" (UUID'be0b0518-35a1-4d10-b7f1-1b61355fa741')) AS t (uuid_col)",
283+
"VALUES UUID'be0b0518-35a1-4d10-b7f1-1b61355fa741'");
284+
}
275285
}

0 commit comments

Comments
 (0)