{"record":{"id":"a36e22146e053ee0","repo":"prestodb/presto","slug":"bigquery-unsupported-type-for-long","errorCode":"BIGQUERY_UNSUPPORTED_TYPE_FOR_LONG","errorMessage":"Unhandled type for %s: %s","messagePattern":"Unhandled type for (.+?): (.+?)","errorType":"error_code","errorClass":"BigQueryException","httpStatus":null,"severity":"error","filePath":"presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryResultPageSource.java","lineNumber":212,"sourceCode":"    private void writeLong(Type type, Object value, BlockBuilder output, Class<?> javaType)\n    {\n        if (type.equals(BIGINT)) {\n            type.writeLong(output, ((Number) value).longValue());\n        }\n        else if (type.equals(INTEGER)) {\n            type.writeLong(output, ((Number) value).intValue());\n        }\n        else if (type.equals(DATE)) {\n            type.writeLong(output, ((Number) value).intValue());\n        }\n        else if (type.equals(TIMESTAMP)) {\n            type.writeLong(output, BigQueryType.toPrestoTimestamp(((org.apache.avro.util.Utf8) value).toString()));\n        }\n        else if (type.equals(TIME_WITH_TIME_ZONE) || type.equals(TIMESTAMP_WITH_TIME_ZONE)) {\n            type.writeLong(output, DateTimeEncoding.packDateTimeWithZone(((Long) value).longValue() / 1000, TimeZoneKey.UTC_KEY));\n        }\n        else {\n            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());","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryResultPageSource.java#L194-L230","documentation":"This error is thrown by BigQueryResultPageSource.writeLong when converting an Avro value into a Presto column whose Type expects a long (e.g. BIGINT, timestamps), but the column's Presto type is none of the supported timestamp types handled above the throw. It indicates a mapping gap between BigQuery/Avro schema types and Presto types in the bigquery plugin.","triggerScenarios":"Reading BigQuery rows via a page source where appendTo dispatches to writeLong with a Presto type that is not TIME_WITH_TIME_ZONE, TIMESTAMP_WITH_TIME_ZONE (nor the other handled timestamp variants), e.g. an unexpected type signature reaching the long-writing branch.","commonSituations":"BigQuery schema changes adding column types not covered by the plugin's type mapping; custom/aliased timestamp types; plugin version older than a newly supported BigQuery type.","solutions":["Inspect the Presto type and the Avro value class named in the message and add an explicit mapping branch in writeLong for that type","Upgrade the presto-bigquery plugin to a version that supports the BigQuery type","Cast or exclude the offending column in the query (e.g. CAST to a supported type or select only supported columns)","File/track a plugin issue for the unsupported type combination"],"exampleFix":"// before\nelse {\n    throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_LONG, format(\"Unhandled type for %s: %s\", javaType.getSimpleName(), type));\n}\n// after\nelse if (type.equals(BIGINT)) {\n    type.writeLong(output, ((Number) value).longValue());\n}\nelse {\n    throw new BigQueryException(BIGQUERY_UNSUPPORTED_TYPE_FOR_LONG, format(\"Unhandled type for %s: %s\", javaType.getSimpleName(), type));\n}","handlingStrategy":"type-guard","validationCode":"// before querying, check column types against supported set\nfor (ColumnMetadata col : connectorTable.getColumns()) {\n    Type t = col.getType();\n    if (!(t.equals(TIME_WITH_TIME_ZONE) || t.equals(TIMESTAMP_WITH_TIME_ZONE) || t.equals(BIGINT))) {\n        throw new IllegalStateException(\"Column \" + col.getName() + \" has unsupported type \" + t);\n    }\n}","typeGuard":"boolean isSupportedLongType(Type type) {\n    return type.equals(TIME_WITH_TIME_ZONE)\n        || type.equals(TIMESTAMP_WITH_TIME_ZONE)\n        || type.equals(BIGINT);\n}","tryCatchPattern":"try {\n    pageSource.getNextPage(...);\n} catch (BigQueryException e) {\n    if (e.getErrorCode().getCode() == BIGQUERY_UNSUPPORTED_TYPE_FOR_LONG.getCode()) {\n        // fall back: cast column in SQL or drop it from the select list\n    } else { throw e; }\n}","preventionTips":["Keep the connector version aligned with the BigQuery types your tables use","CAST unsupported columns to supported types at query time","List table schemas before querying and filter unsupported columns","Pin table schemas so types do not drift unexpectedly"],"tags":["bigquery","type-mapping","avro"],"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"}