Follow-up to #1206, as agreed in #1206 (comment).
Reproduced at ee9f3d20 with the test TPC-H ORDERS schema. Two cases remain:
SELECT SUM(O_TOTALPRICE) OVER (
ORDER BY O_TOTALPRICE RANGE BETWEEN -5.5 PRECEDING AND CURRENT ROW
) FROM ORDERS;
The converter emits a Preceding bound with a decimal offset of -5.5. The magnitude should be positive and the direction should become Following.
SELECT SUM(O_ORDERKEY) OVER (
ORDER BY O_ORDERKEY RANGE BETWEEN -2147483648 PRECEDING AND CURRENT ROW
) FROM ORDERS;
The converter now emits a Preceding bound with an i64 offset of -2147483648. It no longer throws the exception reported at a8bf3d5a; it produces an invalid negative distance instead. The positive magnitude 2147483648 fits the i64 ordering type, but the sign and direction are not normalized.
Spec v0.102.0 requires a non-negative RANGE distance. Normalize the sign and direction while preserving the exact value, then represent the magnitude in the ordering expression's compatible offset type.
Follow-up to #1206, as agreed in #1206 (comment).
Reproduced at
ee9f3d20with the test TPC-HORDERSschema. Two cases remain:The converter emits a
Precedingbound with a decimal offset of-5.5. The magnitude should be positive and the direction should becomeFollowing.The converter now emits a
Precedingbound with ani64offset of-2147483648. It no longer throws the exception reported ata8bf3d5a; it produces an invalid negative distance instead. The positive magnitude2147483648fits thei64ordering type, but the sign and direction are not normalized.Spec v0.102.0 requires a non-negative RANGE distance. Normalize the sign and direction while preserving the exact value, then represent the magnitude in the ordering expression's compatible offset type.