SebastianGruza commented on code in PR #771:
URL: 
https://github.com/apache/hugegraph-toolchain/pull/771#discussion_r4141933741


##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/util/DataTypeUtil.java:
##########
@@ -200,7 +201,15 @@ private static Object parseSingleValue(String key, Object 
rawValue,
             }
         } else if (dataType.isUUID()) {
             return parseUUID(key, value);
+        } else if (dataType.isDecimal()) {
+            return parseDecimal(key, value);
         } else if (dataType.isText()) {
+            if (value instanceof BigDecimal) {
+                // JSON fractions are parsed as BigDecimal (see JsonUtil);
+                // a TEXT key keeps the string the double path produced
+                // ("1.5", not "1.50"), so existing ids do not change
+                return Double.toString(((BigDecimal) value).doubleValue());

Review Comment:
   Good catch, thanks: I moved the same problem from JSON to JDBC. Done the way 
you suggest: the TEXT branch formats a `BigDecimal` through `double` only when 
the value came from the JSON parser (`FileSource`/`HDFSSource` with `format() 
== JSON`, or `KafkaSource` with `getFormat() == JSON`, helper 
`fromJsonParser`); every other `BigDecimal`, including JDBC, keeps 
`value.toString()` as before this PR. 
`DataTypeUtilTest.testConvertJdbcDecimalToTextKeepsItsText` converts your three 
values from a `JDBCSource`: `12.50 -> "12.50"`, `12345 -> "12345"`, 
`12345678901234567890.12` unchanged; the JSON case from round 2 now uses a 
source with `format: JSON` explicitly.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to