opensearch-project / opensearch-project/sql
[BUG] Dedup crashes with ClassCastException
Open
@dai-chen is already working on this.
Since Jul 14, 2026.
bug
PPL
- Dominant language
- Java
- Stars
- 176
- Forks
- 229
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 43
Description
Bug Report
Describe the bug:
PPL DEDUP command crashes with a ClassCastException when:
- The dedup pushdown path is taken (composite aggregation +
top_hits) — i.e., noWHEREclause precedesDEDUP - The index contains any field whose
_sourcerepresentation is a non-primitive (Map/Object), such asgeo_pointstored as{"lat":..., "lon":...}or object-type fields
The top_hits response parser appears to iterate over _source fields and assumes all values are String, but encounters HashMap values from structured field types.
OpenSearch version: 3.7.0 (also reproduces on 3.4.0 with the reversed cast direction)
SQL plugin version: 3.7.0.0
Reproduction
Minimal reproduction:
# Create index with a geo_point field (stored as object in _source)
PUT test_dedup_geo
{
"mappings": {
"properties": {
"name": { "type": "keyword" },
"location": { "type": "geo_point" }
}
}
}
POST test_dedup_geo/_bulk
{"index":{}}
{"name":"alice","location":{"lat":40.7,"lon":-74.0}}
{"index":{}}
{"name":"bob","location":{"lat":34.0,"lon":-118.2}}
{"index":{}}
{"name":"alice","location":{"lat":51.5,"lon":-0.1}}
POST test_dedup_geo/_refresh
# This FAILS:
POST _plugins/_ppl
{"query": "SOURCE = test_dedup_geo | DEDUP name | FIELDS name"}
# This WORKS (WHERE clause prevents dedup pushdown):
POST _plugins/_ppl
{"query": "SOURCE = test_dedup_geo | WHERE name IS NOT NULL | DEDUP name | FIELDS name"}
On 3.7.0:
{
"error": {
"reason": "java.sql.SQLException: exception while executing query: class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')",
"type": "RuntimeException"
},
"status": 500
}
On 3.4.0:
{
"error": {
"reason": "java.sql.SQLException: exception while executing query: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')",
"type": "RuntimeException"
},
"status": 500
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.