Open PChou opened 3 years ago
I think the issue is that we are treating a JSON Number as an integer/long value when it in fact is a floating point value.
I think this should be as easy as reading the value into a double and casting back into long instead (while being aware of when the value is non-integral).
I found that it is parsed to be a FloatNode, which should be regarded as invalid in TestMillisecondsSinceEpochJsonFieldDecoder. There are frequency lost when it is stored in float, the result will be 1618540625920000. Shall we simply cast float to long or judge when parsing node?
@hashhar @JoJoBizarreAdventure If floating-point numbers are supported, there is indeed a loss of precision. We need to decide how to discard units smaller than milliseconds.
@PChou IMO:
Double.parseDouble
to read the values from JSON since JSON doesn't have an integer type.Not that not truncating also has the benefit that it matches the behaviour we already have today.
cc: @losipiuk WDYT?
Not that not truncating also has the benefit that it matches the behaviour we already have today.
I would go with truncating. There is a chance that someone depends on support of non 0 fractional part right now.
Not that not truncating also has the benefit that it matches the behaviour we already have today.
I would go with truncating. There is a chance that someone depends on support of non 0 fractional part right now.
Unlikely because in current code it would throw a NumberFormatException
due to the parseLong
call.
Not that not truncating also has the benefit that it matches the behaviour we already have today.
I would go with truncating. There is a chance that someone depends on support of non 0 fractional part right now.
Unlikely because in current code it would throw a
NumberFormatException
due to theparseLong
call.
Yeah, you are right. Then validation seems fine give any json value representing integer should be represented as integer double
value (without fractional part) under IEEE 754.
trino version: <= 354 I'm testing kafka connector, the source topic data show as below(use kafka console consumer):
notice that, timestamp is represent milliseconds since epoch, but show as scientific notation. Then I try to configure the table descriptor
but the query failed:
from
io/trino/decoder/json/MillisecondsSinceEpochJsonFieldDecoder.java
I found the exception root cause:Failure happens at parseLong("1.618458216014E12")
Since some json framework(ie. jackson) may encode long into the format of scientific notation, do we need to support this case?