prestodb/presto · error · BigQueryException

BIGQUERY_UNSUPPORTED_TYPE_FOR_SLICE

BIGQUERY_UNSUPPORTED_TYPE_FOR_SLICE

Error message

Unhandled type for Slice: 

What it means

writeSlice's final fallback: the Presto column type is neither a VarcharType nor a VarbinaryType, so the connector does not know how to write it as a Slice. It signals an unhandled Presto type in the BigQuery connector's slice-writing path.

Source

Thrown at presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryResultPageSource.java:234

    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;
        }
        if (type instanceof RowType && value instanceof GenericRecord) {
            GenericRecord record = (GenericRecord) value;
            BlockBuilder builder = output.beginBlockEntry();

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Identify the type signature in the message and add a writeSlice branch for it in writeSlice
  2. Upgrade the presto-bigquery plugin to a version supporting that type
  3. Avoid selecting the unsupported column or CAST it to varchar in the query
  4. Track/upvote the connector issue for that type

Example fix

// before
else {
    throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_SLICE, "Unhandled type for Slice: " + type.getTypeSignature());
}
// after
else if (type instanceof CharType) {
    type.writeSlice(output, Slices.utf8Buffer(value.toString()));
}
else {
    throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_SLICE, "Unhandled type for Slice: " + type.getTypeSignature());
}
Defensive patterns

Strategy: validation

Validate before calling

Set<String> supported = Set.of("varchar", "varbinary");
for (ColumnMetadata col : table.getColumns()) {
    String sig = col.getType().getTypeSignature().toString();
    if (!supported.contains(sig.split("\\(")[0])) {
        throw new IllegalStateException("Unsupported slice type: " + sig);
    }
}

Type guard

boolean isSliceBacked(Type type) {
    return type instanceof VarcharType || type instanceof VarbinaryType;
}

Try / catch

try {
    session.execute(query);
} catch (PrestoException e) {
    if (BIGQUERY_UNSUPPORTED_TYPE_FOR_SLICE.getCode() == e.getErrorCode().getCode()) {
        // rewrite query without or casting the offending column
    } else { throw e; }
}

Prevention

When it happens

Trigger: appendTo dispatches writeSlice for a type like CHAR, JSON, or another slice-backed type not explicitly supported by the connector when reading BigQuery results.

Common situations: Querying BigQuery columns whose mapped Presto types (e.g. JSON) are newer than the connector's supported set; connector version lagging behind server features.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/77cd2175d8ce4720. Report an issue: GitHub.