{"record":{"id":"9e881b7d964ac9bd","repo":"prestodb/presto","slug":"bigquery-unsupported-type-for-varbinary","errorCode":"BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY","errorMessage":"Unhandled type for VarBinaryType: ","messagePattern":"Unhandled type for VarBinaryType: ","errorType":"error_code","errorClass":"BigQueryException","httpStatus":null,"severity":"error","filePath":"presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryResultPageSource.java","lineNumber":230,"sourceCode":"            throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_LONG, format(\"Unhandled type for %s: %s\", javaType.getSimpleName(), type));\n        }\n    }\n\n    private void writeSlice(BlockBuilder output, Type type, Object value)\n    {\n        if (type instanceof VarcharType) {\n            type.writeSlice(output, utf8Slice(((Utf8) value).toString()));\n        }\n        else if (type instanceof DecimalType) {\n            BigDecimal bdValue = DECIMAL_CONVERTER.convert(value);\n            type.writeSlice(output, Decimals.encodeScaledValue(bdValue, NUMERIC_DATA_TYPE_SCALE));\n        }\n        else if (type instanceof VarbinaryType) {\n            if (value instanceof ByteBuffer) {\n                type.writeSlice(output, Slices.wrappedBuffer((ByteBuffer) value));\n            }\n            else {\n                throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY, \"Unhandled type for VarBinaryType: \" + value.getClass());\n            }\n        }\n        else {\n            throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_SLICE, \"Unhandled type for Slice: \" + type.getTypeSignature());\n        }\n    }\n\n    private void writeBlock(BlockBuilder output, Type type, Object value)\n    {\n        if (type instanceof ArrayType && value instanceof List<?>) {\n            BlockBuilder builder = output.beginBlockEntry();\n\n            for (Object element : (List<?>) value) {\n                appendTo(type.getTypeParameters().get(0), element, builder);\n            }\n\n            output.closeEntry();\n            return;","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryResultPageSource.java#L212-L248","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nelse {\n    throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY, \"Unhandled type for VarBinaryType: \" + value.getClass());\n}\n// after\nelse if (value instanceof byte[]) {\n    type.writeSlice(output, Slices.wrappedBuffer((byte[]) value));\n}\nelse {\n    throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY, \"Unhandled type for VarBinaryType: \" + value.getClass());\n}","handlingStrategy":"type-guard","validationCode":"// ensure the column's Avro decode class matches expectation\nObject v = record.get(fieldName);\nif (v != null && !(v instanceof ByteBuffer)) {\n    throw new IllegalStateException(\"VARBINARY column decoded as \" + v.getClass());\n}","typeGuard":"boolean isByteBufferValue(Object value) {\n    return value instanceof ByteBuffer || value instanceof byte[];\n}","tryCatchPattern":"try {\n    cursor.advanceNextPosition();\n} catch (BigQueryException e) {\n    if (BIGQUERY_UNSUPPORTED_TYPE_FOR_VARBINARY.getCode() == e.getErrorCode().getCode()) {\n        // re-issue query casting the column: CAST(col AS STRING)\n    } else { throw e; }\n}","preventionTips":["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"],"tags":["bigquery","varbinary","avro","type-mismatch"],"backgroundTag":"unsupported-column-type","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}