Search code examples
apache-flinkflink-streamingflink-sql

ArithmeticException when divide const integer in Flink SQL


Flink throwed ArithmeticException(on-terminating decimal expansion no exact representable decimal result) when I executed below query:

SELECT productId, COUNT(order), COUNT(order)/100.0
From product
GROUP BY productId

I can't find a way from the document or google to get rid of this issue. Thanks.


Solution

  • The exception will be fixed in the upcoming Flink 1.5 release. It is described in this issue. As a workaround you can simply cast to double precision CAST(x AS DOUBLE). Only arithmetics on Java's BigDecimal type (SQL DECIMAL) are affected.