You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2022/01/19 08:50:52 UTC
[incubator-kyuubi] branch master updated: [KYUUBI #1784][FOLLOWUP][TRINO] Fix float types lose precision
This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new a4de0e6 [KYUUBI #1784][FOLLOWUP][TRINO] Fix float types lose precision
a4de0e6 is described below
commit a4de0e67f6fb90e2fb86253e89896a6df6831d56
Author: Fu Chen <cf...@gmail.com>
AuthorDate: Wed Jan 19 16:50:41 2022 +0800
[KYUUBI #1784][FOLLOWUP][TRINO] Fix float types lose precision
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->
### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about the use case of it.
2. If you fix a bug, you can clarify why it is a bug.
-->
The end-to-end test case should be added after the Trino engine test framework has been refined.
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #1802 from cfmcgrady/kyuubi-1784-trino.
Closes #1784
8b19aafb [Fu Chen] fix
Authored-by: Fu Chen <cf...@gmail.com>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
.../main/scala/org/apache/kyuubi/engine/trino/schema/RowSet.scala | 7 +++++--
.../scala/org/apache/kyuubi/engine/trino/schema/RowSetSuite.scala | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/schema/RowSet.scala b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/schema/RowSet.scala
index 5fe4cd4..7ae080c 100644
--- a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/schema/RowSet.scala
+++ b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/schema/RowSet.scala
@@ -114,7 +114,7 @@ object RowSet {
case REAL =>
val values = getOrSetAsNull[java.lang.Float](rows, ordinal, nulls, 0.toFloat)
- .asScala.map(n => java.lang.Double.valueOf(n.toDouble)).asJava
+ .asScala.map(n => java.lang.Double.valueOf(n.toString)).asJava
TColumn.doubleVal(new TDoubleColumn(values, nulls))
case DOUBLE =>
@@ -200,7 +200,10 @@ object RowSet {
case REAL =>
val tDoubleValue = new TDoubleValue
- if (row(ordinal) != null) tDoubleValue.setValue(row(ordinal).asInstanceOf[Float])
+ if (row(ordinal) != null) {
+ val doubleValue = java.lang.Double.valueOf(row(ordinal).asInstanceOf[Float].toString)
+ tDoubleValue.setValue(doubleValue)
+ }
TColumnValue.doubleVal(tDoubleValue)
case DOUBLE =>
diff --git a/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/schema/RowSetSuite.scala b/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/schema/RowSetSuite.scala
index 99b1f0c..d6187bb 100644
--- a/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/schema/RowSetSuite.scala
+++ b/externals/kyuubi-trino-engine/src/test/scala/org/apache/kyuubi/engine/trino/schema/RowSetSuite.scala
@@ -182,7 +182,7 @@ class RowSetSuite extends KyuubiFunSuite {
val floatCol = cols.next().getDoubleVal
floatCol.getValues.asScala.zipWithIndex.foreach {
case (b, 11) => assert(b === 0)
- case (b, i) => assert(b === java.lang.Float.valueOf(s"$i.$i"))
+ case (b, i) => assert(b.toFloat === java.lang.Float.valueOf(s"$i.$i"))
}
val doubleCol = cols.next().getDoubleVal