You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by ki...@apache.org on 2022/08/15 04:22:39 UTC

[incubator-seatunnel] branch dev updated: [Bug][Core] Fixed the bug that BigDecimal could not be converted correctly (#2408)

This is an automated email from the ASF dual-hosted git repository.

kirs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new e898819d9 [Bug][Core] Fixed the bug that BigDecimal could not be converted correctly (#2408)
e898819d9 is described below

commit e898819d900efa0240037f20e4ad08780fe3ff61
Author: TyrantLucifer <Ty...@gmail.com>
AuthorDate: Mon Aug 15 12:22:35 2022 +0800

    [Bug][Core] Fixed the bug that BigDecimal could not be converted correctly (#2408)
    
    * [Bug][Core] Fixed the bug that BigDecimal could not be converted correctly
    
    * [Bug][Core] Fixed the bug that BigDecimal could not be converted correctly
---
 .../spark/common/serialization/InternalRowConverter.java            | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java b/seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java
index 329352f13..0224654d6 100644
--- a/seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java
+++ b/seatunnel-translation/seatunnel-translation-spark/seatunnel-translation-spark-common/src/main/java/org/apache/seatunnel/translation/spark/common/serialization/InternalRowConverter.java
@@ -35,9 +35,11 @@ import org.apache.spark.sql.catalyst.expressions.MutableLong;
 import org.apache.spark.sql.catalyst.expressions.MutableShort;
 import org.apache.spark.sql.catalyst.expressions.MutableValue;
 import org.apache.spark.sql.catalyst.expressions.SpecificInternalRow;
+import org.apache.spark.sql.types.Decimal;
 import org.apache.spark.unsafe.types.UTF8String;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.sql.Date;
 import java.sql.Timestamp;
 import java.time.LocalDate;
@@ -80,6 +82,8 @@ public final class InternalRowConverter extends RowConverter<InternalRow> {
                 return convertMap((Map<?, ?>) field, (MapType<?, ?>) dataType, InternalRowConverter::convert);
             case STRING:
                 return UTF8String.fromString((String) field);
+            case DECIMAL:
+                return Decimal.apply((BigDecimal) field);
             default:
                 return field;
         }
@@ -164,6 +168,8 @@ public final class InternalRowConverter extends RowConverter<InternalRow> {
                 return convertMap((Map<?, ?>) field, (MapType<?, ?>) dataType, InternalRowConverter::reconvert);
             case STRING:
                 return field.toString();
+            case DECIMAL:
+                return ((Decimal) field).toJavaBigDecimal();
             default:
                 return field;
         }