[
https://issues.apache.org/jira/browse/IMPALA-10350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17319639#comment-17319639
]
Amogh Margoor commented on IMPALA-10350:
----------------------------------------
[~boroknagyz] There is another piece to this issue. Apart from what we
discussed above there is an issue even here:
[HdfsTextTableWriter::AppendRows()|https://github.com/apache/impala/blob/622e3c95adca5cf30a0aff6542556feab9b8a861/be/src/exec/hdfs-text-table-writer.cc#L67]
calls GetValue() and then print's into std::stringstream
[rowbatch_stringstream|https://github.com/apache/impala/blob/622e3c95adca5cf30a0aff6542556feab9b8a861/be/src/exec/hdfs-text-table-writer.cc#L104].
The precision of this std::stringstream is by default set to
[16|https://github.com/apache/impala/blob/622e3c95adca5cf30a0aff6542556feab9b8a861/be/src/exec/hdfs-text-table-writer.cc#L51].
It never gets reset except
[here|https://github.com/apache/impala/blob/b28da054f3595bb92873433211438306fc22fbc7/be/src/runtime/raw-value.cc#L220].
But that happens only for MathFunctions::RoundUpTo() in
[ScalarFnCall|https://github.com/apache/impala/blob/b28da054f3595bb92873433211438306fc22fbc7/be/src/exprs/scalar-fn-call.cc#L171].
So even after the fix in the patch above we will see loss in precision due to
this.
Assuming our patch above fixes values till 2^64-1 (in most cases), should we
increase the default scale from 16 to 20 for doubles in PrintValue ? Would that
have any downstream affect ?
> Impala loses double precision because of DECIMAL->DOUBLE cast
> -------------------------------------------------------------
>
> Key: IMPALA-10350
> URL: https://issues.apache.org/jira/browse/IMPALA-10350
> Project: IMPALA
> Issue Type: Bug
> Components: Backend
> Reporter: Zoltán Borók-Nagy
> Assignee: Amogh Margoor
> Priority: Major
> Labels: correctness, ramp-up
> Attachments: test.c
>
>
> Impala might loses presision of double values. Reproduction:
> {noformat}
> create table double_tbl (d double) stored as textfile;
> insert into double_tbl values (-0.43149576573887316);
> {noformat}
> Then inspect the data file:
> {noformat}
> $ hdfs dfs -cat
> /test-warehouse/double_tbl/424097c644088674-c55b910100000000_175064830_data.0.txt
> -0.4314957657388731{noformat}
> The same happens if we store our data in Parquet.
> Hive writes don't lose precision. If the data was written by Hive then Impala
> can read the values correctly:
> {noformat}
> $ bin/run-jdbc-client.sh -t NOSASL -q "select * from double_tbl;"
> Using JDBC Driver Name: org.apache.hive.jdbc.HiveDriver
> Connecting to: jdbc:hive2://localhost:21050/;auth=noSasl
> Executing: select * from double_tbl
> ----[START]----
> -0.43149576573887316
> ----[END]----{noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]