JNSimba commented on code in PR #27:
URL: 
https://github.com/apache/incubator-doris-flink-connector/pull/27#discussion_r850014338


##########
flink-doris-connector/src/main/java/org/apache/doris/flink/table/DorisRowDataInputFormat.java:
##########
@@ -136,15 +147,30 @@ public RowData nextRecord(RowData reuse) throws 
IOException {
             return null;
         }
         List next = (List) scalaValueReader.next();
-        GenericRowData genericRowData = new GenericRowData(next.size());
-        for (int i = 0; i < next.size(); i++) {
-            genericRowData.setField(i, next.get(i));
+        GenericRowData genericRowData = new 
GenericRowData(rowType.getFieldCount());
+        for (int i = 0; i < next.size() && i < rowType.getFieldCount(); i++) {
+            Object value = deserialize(rowType.getTypeAt(i), next.get(i));
+            genericRowData.setField(i, value);
         }
         //update hasNext after we've read the record
         hasNext = scalaValueReader.hasNext();
         return genericRowData;
     }
 
+    private Object deserialize(LogicalType type, Object val) {
+        switch (type.getTypeRoot()) {
+            case DECIMAL:
+                final DecimalType decimalType = ((DecimalType) type);
+                final int precision = decimalType.getPrecision();
+                final int scala = decimalType.getScale();
+                return DecimalData.fromBigDecimal((BigDecimal) val, precision, 
scala);
+            case VARCHAR:
+                return StringData.fromString(val.toString());

Review Comment:
   The `StringData.fromString` conversion in Rowbatch should be removed, 
otherwise an error may be reported here: `StringData cannot be cast to 
java.lang.String`



-- 
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