From 6175d240836472e073aac53df98e6f43cc079ebc Mon Sep 17 00:00:00 2001 From: laglangyue <373435126@qq.com> Date: Sun, 14 Aug 2022 09:37:52 +0800 Subject: [PATCH] update decimalType random --- .../connectors/seatunnel/fake/source/FakeData.java | 8 ++------ .../spark/common/serialization/InternalRowConverter.java | 4 ---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/seatunnel-connectors-v2/connector-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeData.java b/seatunnel-connectors-v2/connector-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeData.java index 868a197eb290..1639e5b0e490 100644 --- a/seatunnel-connectors-v2/connector-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeData.java +++ b/seatunnel-connectors-v2/connector-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeData.java @@ -17,7 +17,6 @@ package org.apache.seatunnel.connectors.seatunnel.fake.source; -import java.time.LocalDateTime; import org.apache.seatunnel.api.table.type.BasicType; import org.apache.seatunnel.api.table.type.DecimalType; import org.apache.seatunnel.api.table.type.LocalTimeType; @@ -29,6 +28,7 @@ import org.apache.commons.lang3.RandomUtils; import java.math.BigDecimal; +import java.time.LocalDateTime; public class FakeData { @@ -77,7 +77,7 @@ public static SeaTunnelRow generateRow() { RandomUtils.nextFloat(Float.MIN_VALUE, Float.MAX_VALUE), RandomUtils.nextDouble(Float.MAX_VALUE, Double.MAX_VALUE), RandomStringUtils.randomAlphabetic(10), - BigDecimal.valueOf(RandomUtils.nextLong(Integer.MAX_VALUE,Long.MAX_VALUE),18), + BigDecimal.valueOf(RandomUtils.nextLong(Integer.MAX_VALUE, Long.MAX_VALUE), 18), LocalDateTime.now(), LocalDateTime.now().toLocalDate(), LocalDateTime.now().toLocalTime(), @@ -88,8 +88,4 @@ public static SeaTunnelRow generateRow() { } return new SeaTunnelRow(columnValue); } - - public static void main(String[] args) { - System.out.println(BigDecimal.valueOf(RandomUtils.nextDouble(0, Long.MAX_VALUE))); - } } 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 d8b0fd901b8e..329352f13049 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 @@ -17,7 +17,6 @@ package org.apache.seatunnel.translation.spark.common.serialization; -import java.math.BigDecimal; import org.apache.seatunnel.api.table.type.MapType; import org.apache.seatunnel.api.table.type.SeaTunnelDataType; import org.apache.seatunnel.api.table.type.SeaTunnelRow; @@ -36,7 +35,6 @@ 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; @@ -82,8 +80,6 @@ private static Object convert(Object field, SeaTunnelDataType dataType) { 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; }