Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kafka-connect/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ project(':iceberg-kafka-connect:iceberg-kafka-connect') {
testImplementation libs.hadoop3.client
testRuntimeOnly project(':iceberg-parquet')
testRuntimeOnly project(':iceberg-orc')
testImplementation project(path: ':iceberg-api', configuration: 'testArtifacts')
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.iceberg.FileFormat;
import org.apache.iceberg.Schema;
import org.apache.iceberg.Table;
import org.apache.iceberg.TableProperties;
Expand All @@ -59,7 +61,9 @@
import org.apache.iceberg.types.Types.NestedField;
import org.apache.iceberg.types.Types.StructType;
import org.apache.iceberg.types.Types.TimestampType;
import org.apache.iceberg.util.ByteBuffers;
import org.apache.iceberg.util.DateTimeUtil;
import org.apache.iceberg.util.UUIDUtil;
import org.apache.kafka.connect.data.Struct;

class RecordConverter {
Expand Down Expand Up @@ -128,8 +132,9 @@ private Object convertValue(
case UUID:
return convertUUID(value);
case BINARY:
case FIXED:
return convertBase64Binary(value);
case FIXED:
return ByteBuffers.toByteArray(convertBase64Binary(value));
case DATE:
return convertDateValue(value);
case TIME:
Expand Down Expand Up @@ -388,13 +393,24 @@ protected String convertString(Object value) {
throw new IllegalArgumentException("Cannot convert to string: " + value.getClass().getName());
}

protected UUID convertUUID(Object value) {
protected Object convertUUID(Object value) {
UUID uuid;
if (value instanceof String) {
return UUID.fromString((String) value);
uuid = UUID.fromString((String) value);
} else if (value instanceof UUID) {
return (UUID) value;
uuid = (UUID) value;
} else {
throw new IllegalArgumentException("Cannot convert to UUID: " + value.getClass().getName());
}

if (FileFormat.PARQUET
.name()
.toLowerCase(Locale.ROOT)
.equals(config.writeProps().get(TableProperties.DEFAULT_FILE_FORMAT))) {
return UUIDUtil.convert(uuid);
} else {
return uuid;
}
throw new IllegalArgumentException("Cannot convert to UUID: " + value.getClass().getName());
}

protected ByteBuffer convertBase64Binary(Object value) {
Expand Down
Loading