This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 4d6310cd582 [fix][sql][branch-3.0] Fix UUID convert failed for JSON 
schema (#23292)
4d6310cd582 is described below

commit 4d6310cd5828245bb9fe9429f837e11aa8bad565
Author: Baodi Shi <[email protected]>
AuthorDate: Thu Sep 12 20:30:24 2024 +0800

    [fix][sql][branch-3.0] Fix UUID convert failed for JSON schema (#23292)
---
 .../pulsar/sql/presto/decoder/json/PulsarJsonFieldDecoder.java       | 5 +++++
 .../org/apache/pulsar/sql/presto/decoder/json/TestJsonDecoder.java   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/decoder/json/PulsarJsonFieldDecoder.java
 
b/pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/decoder/json/PulsarJsonFieldDecoder.java
index 8e744e3b122..c396fbb85e2 100644
--- 
a/pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/decoder/json/PulsarJsonFieldDecoder.java
+++ 
b/pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/decoder/json/PulsarJsonFieldDecoder.java
@@ -64,6 +64,7 @@ import io.trino.spi.type.VarcharType;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 import org.apache.commons.lang3.tuple.Pair;
 
 /**
@@ -276,6 +277,10 @@ public class PulsarJsonFieldDecoder
         private static Slice getSlice(JsonNode value, Type type, String 
columnName) {
             String textValue = value.isValueNode() ? value.asText() : 
value.toString();
 
+            if (type instanceof UuidType) {
+                return 
UuidType.javaUuidToTrinoUuid(UUID.fromString(textValue));
+            }
+
             Slice slice = utf8Slice(textValue);
             if (type instanceof VarcharType) {
                 slice = truncateToLength(slice, type);
diff --git 
a/pulsar-sql/presto-pulsar/src/test/java/org/apache/pulsar/sql/presto/decoder/json/TestJsonDecoder.java
 
b/pulsar-sql/presto-pulsar/src/test/java/org/apache/pulsar/sql/presto/decoder/json/TestJsonDecoder.java
index 32e71a53444..a5207d00124 100644
--- 
a/pulsar-sql/presto-pulsar/src/test/java/org/apache/pulsar/sql/presto/decoder/json/TestJsonDecoder.java
+++ 
b/pulsar-sql/presto-pulsar/src/test/java/org/apache/pulsar/sql/presto/decoder/json/TestJsonDecoder.java
@@ -144,7 +144,7 @@ public class TestJsonDecoder extends AbstractDecoderTester {
 
         PulsarColumnHandle uuidHandle = new 
PulsarColumnHandle(getPulsarConnectorId().toString(),
                 "uuidField", UuidType.UUID, false, false, "uuidField", null, 
null, PulsarColumnHandle.HandleKeyValueType.NONE);
-        checkValue(decodedRow, uuidHandle, message.uuidField.toString());
+        checkValue(decodedRow, uuidHandle, 
UuidType.javaUuidToTrinoUuid(message.uuidField));
     }
 
     @Test

Reply via email to