prestodb/presto · error · BigQueryException
BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY
BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY
Error message
Unhandled type for VarBinaryType:
What it means
writeSlice throws this when the Presto column type is VarbinaryType but the Avro value from BigQuery is not a java.nio.ByteBuffer, so it cannot be wrapped into a Slice. It is a value-shape mismatch inside the BigQuery connector's row decoding.
Source
Thrown at presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryResultPageSource.java:230
throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_LONG, format("Unhandled type for %s: %s", javaType.getSimpleName(), type));
}
}
private void writeSlice(BlockBuilder output, Type type, Object value)
{
if (type instanceof VarcharType) {
type.writeSlice(output, utf8Slice(((Utf8) value).toString()));
}
else if (type instanceof DecimalType) {
BigDecimal bdValue = DECIMAL_CONVERTER.convert(value);
type.writeSlice(output, Decimals.encodeScaledValue(bdValue, NUMERIC_DATA_TYPE_SCALE));
}
else if (type instanceof VarbinaryType) {
if (value instanceof ByteBuffer) {
type.writeSlice(output, Slices.wrappedBuffer((ByteBuffer) value));
}
else {
throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY, "Unhandled type for VarBinaryType: " + value.getClass());
}
}
else {
throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_SLICE, "Unhandled type for Slice: " + type.getTypeSignature());
}
}
private void writeBlock(BlockBuilder output, Type type, Object value)
{
if (type instanceof ArrayType && value instanceof List<?>) {
BlockBuilder builder = output.beginBlockEntry();
for (Object element : (List<?>) value) {
appendTo(type.getTypeParameters().get(0), element, builder);
}
output.closeEntry();
return;View on GitHub (pinned to 55bb57d202)
Solutions
- Check the value class printed in the message and add a conversion branch (e.g. handle Utf8/String via getBytes) before the throw
- Align the BigQuery column type so it decodes to bytes (ByteBuffer) in Avro
- Upgrade the connector/Avro libraries to versions that normalize the value type
- Cast the column in SQL (e.g. to varchar) or exclude it
Example fix
// before
else {
throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY, "Unhandled type for VarBinaryType: " + value.getClass());
}
// after
else if (value instanceof byte[]) {
type.writeSlice(output, Slices.wrappedBuffer((byte[]) value));
}
else {
throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY, "Unhandled type for VarBinaryType: " + value.getClass());
} Defensive patterns
Strategy: type-guard
Validate before calling
// ensure the column's Avro decode class matches expectation
Object v = record.get(fieldName);
if (v != null && !(v instanceof ByteBuffer)) {
throw new IllegalStateException("VARBINARY column decoded as " + v.getClass());
} Type guard
boolean isByteBufferValue(Object value) {
return value instanceof ByteBuffer || value instanceof byte[];
} Try / catch
try {
cursor.advanceNextPosition();
} catch (BigQueryException e) {
if (BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY.getCode() == e.getErrorCode().getCode()) {
// re-issue query casting the column: CAST(col AS STRING)
} else { throw e; }
} Prevention
- Keep bytes-typed BigQuery columns free of logical-type overrides
- Test schema changes against the connector before deploying
- CAST VARBINARY columns to STRING if the connector mis-decodes
- Pin Avro/connector library versions
When it happens
Trigger: A column mapped to Presto VARBINARY whose Avro-decoded value class is anything other than ByteBuffer (message includes the actual class, e.g. java.lang.String).
Common situations: Avro schema evolution changing a bytes field to string/Utf8; upstream tooling writing logical types that decode to different Java classes; connector/A驱逐vro library version differences.
Related errors
- BIGQUERY_UNSUPPORTED_TYPE_FOR_LONG
- BIGQUERY_ERROR_END_OF_AVRO_BUFFER
- BIGQUERY_ERROR_READING_NEXT_AVRO_RECORD
- ELASTICSEARCH_TYPE_MISMATCH
- DECODER_CONVERSION_NOT_SUPPORTED
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/9e881b7d964ac9bd.
Report an issue: GitHub.