You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Mulan (Jira)" <ji...@apache.org> on 2020/11/16 10:33:00 UTC

[jira] [Updated] (FLINK-20170) json deserialize loses precision

     [ https://issues.apache.org/jira/browse/FLINK-20170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mulan updated FLINK-20170:
--------------------------
    Description: 
{code:java}
CREATE TABLE ods (
    id BIGINT,
    factor DECIMAL(38, 18)
) WITH (
    'connector.type' = 'kafka',
    'connector.version' = 'universal',
    'connector.topic' = '_foo',
    'connector.topic?' = '_foo',
    'connector.properties.bootstrap.servers' = 'localhost:9092',
    'connector.properties.group.id' = 'g',
    'format.type' = 'json',
    'update-mode' = 'append'


);
{code}

this following is input data.
{code:json}
{"id": 1, "factor": 799.929496989092949698}
{code}

this following is output data and loses precision.
{code:json}
1, 799.929496989093000000
{code}

This following code call readTree() method. This method make value loses 

{code:java}
	public Row deserialize(byte[] message) throws IOException {
		try {
			final JsonNode root = objectMapper.readTree(message);
			return (Row) runtimeConverter.convert(objectMapper, root);
		} catch (Throwable t) {
			throw new IOException("Failed to deserialize JSON object.", t);
		}
	}
{code}



  was:
{code:java}
CREATE TABLE ods (
    id BIGINT,
    factor DECIMAL(38, 18)
) WITH (
    'connector.type' = 'kafka',
    'connector.version' = 'universal',
    'connector.topic' = '_foo',
    'connector.topic?' = '_foo',
    'connector.properties.bootstrap.servers' = 'localhost:9092',
    'connector.properties.group.id' = 'g',
    'format.type' = 'json',
    'update-mode' = 'append'


);
{code}

this following is input data.
{code:json}
{"id": 1, "factor": 799.929496989092949698}
{code}

this following is output data and loses precision.
{code:json}
1, 799.929496989093000000
{code}

{code:java}
	public Row deserialize(byte[] message) throws IOException {
		try {
			final JsonNode root = objectMapper.readTree(message);
			return (Row) runtimeConverter.convert(objectMapper, root);
		} catch (Throwable t) {
			throw new IOException("Failed to deserialize JSON object.", t);
		}
	}
{code}




> json deserialize loses precision
> --------------------------------
>
>                 Key: FLINK-20170
>                 URL: https://issues.apache.org/jira/browse/FLINK-20170
>             Project: Flink
>          Issue Type: Improvement
>          Components: Formats (JSON, Avro, Parquet, ORC, SequenceFile), Table SQL / API
>            Reporter: Mulan
>            Priority: Major
>
> {code:java}
> CREATE TABLE ods (
>     id BIGINT,
>     factor DECIMAL(38, 18)
> ) WITH (
>     'connector.type' = 'kafka',
>     'connector.version' = 'universal',
>     'connector.topic' = '_foo',
>     'connector.topic?' = '_foo',
>     'connector.properties.bootstrap.servers' = 'localhost:9092',
>     'connector.properties.group.id' = 'g',
>     'format.type' = 'json',
>     'update-mode' = 'append'
> );
> {code}
> this following is input data.
> {code:json}
> {"id": 1, "factor": 799.929496989092949698}
> {code}
> this following is output data and loses precision.
> {code:json}
> 1, 799.929496989093000000
> {code}
> This following code call readTree() method. This method make value loses 
> {code:java}
> 	public Row deserialize(byte[] message) throws IOException {
> 		try {
> 			final JsonNode root = objectMapper.readTree(message);
> 			return (Row) runtimeConverter.convert(objectMapper, root);
> 		} catch (Throwable t) {
> 			throw new IOException("Failed to deserialize JSON object.", t);
> 		}
> 	}
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)