calcite
calcite copied to clipboard
[CALCITE-5607] Datetime MINUS throws ArrayIndexOutOfBounds error when…
… serializing toRex
Uncovered a bug in RelJson#toRex for the TIMESTAMP_DIFF call for Big Query dialect which is translated to Datetime MINUS. MINUS_DATE uses an ARG2_NULLABLE return type inference which requires 3 operands, however there are only 2 operands for BQ. The solution is to add in "type" when serializing to JSON in RelJson.toJson(RexNode node) [like we do for CAST] so that jsonType will be defined in toRex and it doesn't rely on the operands.
Co-authored-by: TJ Banghart [email protected]