You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ClassCastException: ArrayList cannot be cast to Long on multi-valued long fields #5232
PPL queries that perform expressions (eval, arithmetic, comparisons) on multi-valued long fields throw ClassCastException when the Calcite engine is enabled.
Error
{
"error": {
"reason": "There was internal problem at backend",
"details": "class java.util.ArrayList cannot be cast to class java.lang.Long",
"type": "ClassCastException"
},
"status": 500
}
Reproduction
Index with a long field containing array data:
PUT /test_index/_doc/1
{"response_times": [120, 350, 90], "message": "ok"}
Hi @LantaoJin@ahkcs The issue is that Calcite maps long fields as scalar BIGINT since OpenSearch mappings don't distinguish single vs multi-valued fields. At runtime, multi-valued fields come back as ArrayList but generated code expects Long, causing the ClassCastException.
For now, I've caught the ClassCastException and converted it to a 400 ExpressionEvaluationException with a clear error message, matching v2 engine behaviour.
Please let me know your thoughts.
In the long-term solution, it could be resolved by dynamic type inference/resolution at runtime. Maybe it belongs to that meta issue instead of a bug. Related to: #4984
Activity
sunil9977 commentedon Mar 26, 2026
Hi @ahkcs , Could you please assign it to me?
LantaoJin commentedon Mar 31, 2026
@ahkcs what behavior do you expected?
LantaoJin commentedon Mar 31, 2026
IMO, we can permanently fix it as long as we could identify a field is multivalued, I found there is an issue open in Lucene apache/lucene#15794.
sunil9977 commentedon Apr 1, 2026
Hi @LantaoJin @ahkcs The issue is that Calcite maps long fields as scalar BIGINT since OpenSearch mappings don't distinguish single vs multi-valued fields. At runtime, multi-valued fields come back as ArrayList but generated code expects Long, causing the
ClassCastException.For now, I've caught the
ClassCastExceptionand converted it to a 400ExpressionEvaluationExceptionwith a clear error message, matching v2 engine behaviour.Please let me know your thoughts.
Fix ArrayList cast to Long for multivalue fields in script execution (o…
Rework multivalue unwrap to only scalarize for numeric types (opensea…
songkant-aws commentedon Apr 9, 2026
In the long-term solution, it could be resolved by dynamic type inference/resolution at runtime. Maybe it belongs to that meta issue instead of a bug. Related to: #4984
qianheng-aws commentedon Apr 10, 2026
Closing as duplicate of #5333 — consolidated umbrella issue for array values not treated as atomic values.