Skip to content

Commit

Permalink
[fix][sql][branch-3.0] Fix UUID convert failed for JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shibd committed Sep 12, 2024
1 parent 37adbe8 commit e7ff036
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang3.tuple.Pair;

/**
Expand Down Expand Up @@ -276,6 +277,10 @@ public static double getDouble(JsonNode value, Type type, String columnName) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void testPrimitiveType() {

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
Expand Down

0 comments on commit e7ff036

Please sign in to comment.