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
Optimize type casting workaround in addtotals/addcoltotals aggregation logic #4952
A workaround was implemented in PR #4754 to handle type casting issues when performing UNION operations between original data and aggregated totals in the addtotals/addcoltotals commands.
Current Implementation
The method getAggregateDataTypeFieldRef (line 2529 in CalciteRelNodeVisitor.java) explicitly casts:
INTEGER → BIGINT
FLOAT/REAL → DOUBLE
This workaround prevents ClassCastException that occurs during UNION operations when Calcite automatically converts aggregation result types.
Problem
When combining original data (with int/float types) and aggregated totals (Calcite converts to long/double), a ClassCastException occurs in multi-node scenarios:
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long
at org.apache.calcite.avatica.util.AbstractCursor$LongAccessor.getLong
at org.opensearch.sql.opensearch.util.JdbcOpenSearchDataTypeConvertor.getExprValueFromSqlType
This issue only manifests in CrossClusterSearchIT tests when multi-node results are combined.
Expected Optimization
Investigate whether:
This is a Calcite bug that should be reported upstream
There's a better way to handle type compatibility in UNION operations
The type conversion can be handled more elegantly at a different layer
Activity