prestodb/presto · error · PrestoException
ELASTICSEARCH_TYPE_MISMATCH
ELASTICSEARCH_TYPE_MISMATCH
Error message
Expected a numeric value for field %s of type BIGINT: %s [%s]
What it means
BigintDecoder decodes a field declared as BIGINT. A null decodes to NULL and a Number is written as a long, but any other JSON value (string, boolean, object) throws PrestoException(ELASTICSEARCH_TYPE_MISMATCH) — the document value cannot be coerced to BIGINT.
Source
Thrown at presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/BigintDecoder.java:48
private final String path;
public BigintDecoder(String path)
{
this.path = requireNonNull(path, "path is null");
}
@Override
public void decode(Hit hit, Supplier<Object> getter, BlockBuilder output)
{
Object value = getter.get();
if (value == null) {
output.appendNull();
}
else if (value instanceof Number) {
BIGINT.writeLong(output, ((Number) value).longValue());
}
else {
throw new PrestoException(ELASTICSEARCH_TYPE_MISMATCH, format("Expected a numeric value for field %s of type BIGINT: %s [%s]", path, value, value.getClass().getSimpleName()));
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Fix or reindex the offending documents so the field is numeric.
- Correct the Presto column type in the schema to match the ES mapping (e.g. VARCHAR for keyword).
- Add validation/coercion in the ingestion pipeline to guarantee numeric values.
- Clean up documents with the bad value using update_by_query or a reindex script.
Example fix
// before (document)
{ "user_id": "12345" }
// after
{ "user_id": 12345 } Defensive patterns
Strategy: validation
Validate before calling
// find documents with non-numeric values in a BIGINT field
curl -s 'localhost:9200/<index>/_search' -H 'Content-Type: application/json' -d '{
"query": { "bool": { "must_not": [ { "term": { "user_id": { "value": 1 } } } ] } },
"script_fields": {} }'
# better: use a script query checking isinstance(value, int) on user_id Try / catch
try {
rs = stmt.executeQuery("SELECT user_id FROM es.default.idx");
} catch (PrestoException e) {
if (e.getErrorCode().getName().equals("ELASTICSEARCH_TYPE_MISMATCH")) {
// locate and reindex documents where user_id is a string
} else { throw e; }
} Prevention
- Declare Presto columns to match the ES mapping exactly.
- Coerce types in the ingestion pipeline (numbers, not strings).
- Spot-check documents with a script query after pipeline changes.
When it happens
Trigger: A document stores a non-numeric value (e.g. "age": "42" as a string, or "age": true) in a field the Presto table declares as BIGINT; thrown while decoding rows during a scan.
Common situations: Dynamic mapping mapped the field as long in one document but later documents wrote strings; schema in Presto DDL does not match the ES mapping (keyword/text field declared as BIGINT); ingestion pipeline regression.
Related errors
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/48d42f3d4747a9c2.
Report an issue: GitHub.