Skip to content

Commit fe19447

Browse files
Reducing to the numeric POJO property to DOUBLE
1 parent e653694 commit fe19447

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

fluss-client/src/main/java/org/apache/fluss/client/converter/PojoToRowConverter.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,8 @@ private static int truncateNanos(int nanos, int precision) {
420420
if (v == null) {
421421
return null;
422422
}
423-
if (v instanceof Double) {
424-
return (Double) v;
425-
}
426-
if (v instanceof Float) {
427-
return ((Float) v).doubleValue(); // float -> double widening
428-
}
429-
if (v instanceof Long) {
430-
return ((Long) v).doubleValue(); // long -> double widening
431-
}
432-
if (v instanceof Integer) {
433-
return ((Integer) v).doubleValue(); // int -> double widening
434-
}
435-
if (v instanceof Short) {
436-
return ((Short) v).doubleValue(); // short -> double widening
437-
}
438-
if (v instanceof Byte) {
439-
return ((Byte) v).doubleValue(); // byte -> double widening
423+
if (v instanceof Number) {
424+
return ((Number) v).doubleValue();
440425
}
441426
throw new IllegalArgumentException(
442427
String.format(

fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/utils/PojoToRowConverter.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -485,23 +485,8 @@ private static Object convertToDouble(Field field, Object value)
485485
if (value == null) {
486486
return null;
487487
}
488-
if (value instanceof Double) {
489-
return value;
490-
}
491-
if (value instanceof Float) {
492-
return ((Float) value).doubleValue();
493-
}
494-
if (value instanceof Long) {
495-
return ((Long) value).doubleValue();
496-
}
497-
if (value instanceof Integer) {
498-
return ((Integer) value).doubleValue();
499-
}
500-
if (value instanceof Short) {
501-
return ((Short) value).doubleValue();
502-
}
503-
if (value instanceof Byte) {
504-
return ((Byte) value).doubleValue();
488+
if (value instanceof Number) {
489+
return ((Number) value).doubleValue();
505490
}
506491
throw new IllegalArgumentException(
507492
"Field " + field.getName() + " cannot be converted to DOUBLE");

0 commit comments

Comments
 (0)