Skip to content

Commit 86c66b2

Browse files
authored
[fix][sql][branch-3.0] Fix UUID convert failed for JSON schema (#23292)
1 parent 46859c8 commit 86c66b2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/decoder/json/PulsarJsonFieldDecoder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import java.util.Iterator;
6565
import java.util.List;
6666
import java.util.Map;
67+
import java.util.UUID;
6768
import org.apache.commons.lang3.tuple.Pair;
6869

6970
/**
@@ -276,6 +277,10 @@ public static double getDouble(JsonNode value, Type type, String columnName) {
276277
private static Slice getSlice(JsonNode value, Type type, String columnName) {
277278
String textValue = value.isValueNode() ? value.asText() : value.toString();
278279

280+
if (type instanceof UuidType) {
281+
return UuidType.javaUuidToTrinoUuid(UUID.fromString(textValue));
282+
}
283+
279284
Slice slice = utf8Slice(textValue);
280285
if (type instanceof VarcharType) {
281286
slice = truncateToLength(slice, type);

pulsar-sql/presto-pulsar/src/test/java/org/apache/pulsar/sql/presto/decoder/json/TestJsonDecoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void testPrimitiveType() {
144144

145145
PulsarColumnHandle uuidHandle = new PulsarColumnHandle(getPulsarConnectorId().toString(),
146146
"uuidField", UuidType.UUID, false, false, "uuidField", null, null, PulsarColumnHandle.HandleKeyValueType.NONE);
147-
checkValue(decodedRow, uuidHandle, message.uuidField.toString());
147+
checkValue(decodedRow, uuidHandle, UuidType.javaUuidToTrinoUuid(message.uuidField));
148148
}
149149

150150
@Test

0 commit comments

Comments
 (0)