prestodb/presto · error · PrestoException

ELASTICSEARCH_TYPE_MISMATCH

ELASTICSEARCH_TYPE_MISMATCH

Error message

Expected a numeric value for field %s of type DOUBLE: %s [%s]

What it means

DoubleDecoder decodes a field declared as DOUBLE. Null decodes to NULL and a Number is written as a double; any other value (string, boolean, object) throws PrestoException(ELASTICSEARCH_TYPE_MISMATCH) since the value cannot be converted to a floating-point number.

Source

Thrown at presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/DoubleDecoder.java:48

    private final String path;

    public DoubleDecoder(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) {
            DOUBLE.writeDouble(output, ((Number) value).doubleValue());
        }
        else {
            throw new PrestoException(ELASTICSEARCH_TYPE_MISMATCH, format("Expected a numeric value for field %s of type DOUBLE: %s [%s]", path, value, value.getClass().getSimpleName()));
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fix/reindex the documents so the field holds numeric JSON values.
  2. Declare the column as VARCHAR in Presto and cast (CAST(price AS DOUBLE)) in queries if strings are intentional.
  3. Add an ES ingest pipeline with a convert processor (string -> double) to normalize on write.
  4. Align mappings across all indices covered by the queried alias/pattern.

Example fix

// before (document)
{ "price": "9.99" }
// after
{ "price": 9.99 }
Defensive patterns

Strategy: validation

Validate before calling

// find documents whose double field is a string
curl -s 'localhost:9200/<index>/_search' -H 'Content-Type: application/json' -d '{
  "query": { "bool": { "filter": { "script": { "script": {
    "source": "doc[\"price\"].size()!=0 && !(doc[\"price\"].value instanceof Number)"
  } } } } } }'

Try / catch

try {
    rs = stmt.executeQuery("SELECT price FROM es.default.idx");
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("ELASTICSEARCH_TYPE_MISMATCH")) {
        // reindex with convert processor: string -> double for price
    } else { throw e; }
}

Prevention

When it happens

Trigger: A document stores a non-numeric value (e.g. "price": "9.99" as a string, or "price": "N/A") in a field declared DOUBLE; thrown during scan-time decoding.

Common situations: Ingestion pipeline writes numeric fields as strings; sentinel values like "N/A" or "" in data originally exported from spreadsheets; ES mapping drift between float/double and keyword/text across documents or indices under one alias.

Related errors


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