Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cast for Proto type #2862

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,10 @@ private Object writeReplace() {
case PROTO:
builder
.set(fieldName)
.to(Value.protoMessage((ByteArray) value, fieldType.getProtoTypeFqn()));
.to(
Value.protoMessage(
value == null ? null : ((LazyByteArray) value).getByteArray(),
fieldType.getProtoTypeFqn()));
break;
case ENUM:
builder.set(fieldName).to(Value.protoEnum((Long) value, fieldType.getProtoTypeFqn()));
Expand Down Expand Up @@ -817,7 +820,8 @@ protected Value getValueInternal(int columnIndex) {
case INT64:
return Value.int64(isNull ? null : getLongInternal(columnIndex));
case ENUM:
return Value.protoEnum(getLongInternal(columnIndex), columnType.getProtoTypeFqn());
return Value.protoEnum(
isNull ? null : getLongInternal(columnIndex), columnType.getProtoTypeFqn());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @olavloite . Figured this null issue from your latest commit, but adding the fix here to take it in this release.
Hope that is fine with you.

case NUMERIC:
return Value.numeric(isNull ? null : getBigDecimalInternal(columnIndex));
case PG_NUMERIC:
Expand All @@ -833,7 +837,8 @@ protected Value getValueInternal(int columnIndex) {
case BYTES:
return Value.internalBytes(isNull ? null : getLazyBytesInternal(columnIndex));
case PROTO:
return Value.protoMessage(getBytesInternal(columnIndex), columnType.getProtoTypeFqn());
return Value.protoMessage(
isNull ? null : getBytesInternal(columnIndex), columnType.getProtoTypeFqn());
case TIMESTAMP:
return Value.timestamp(isNull ? null : getTimestampInternal(columnIndex));
case DATE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,16 @@ public List<Boolean> getBooleanList(String columnName) {

@Override
public long[] getLongArray(int columnIndex) {
checkNonNullOfType(columnIndex, Type.array(Type.int64()), columnIndex);
checkNonNullOfCodes(columnIndex, Collections.singletonList(Code.ARRAY), columnIndex);
checkArrayElementType(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnIndex);
return getLongArrayInternal(columnIndex);
}

@Override
public long[] getLongArray(String columnName) {
int columnIndex = getColumnIndex(columnName);
checkNonNullOfType(columnIndex, Type.array(Type.int64()), columnName);
checkNonNullOfCodes(columnIndex, Collections.singletonList(Code.ARRAY), columnName);
checkArrayElementType(columnIndex, Arrays.asList(Code.ENUM, Code.INT64), columnName);
return getLongArrayInternal(columnIndex);
}

Expand Down