JNSimba commented on a change in pull request #15:
URL:
https://github.com/apache/incubator-doris-spark-connector/pull/15#discussion_r834994762
##########
File path:
spark-doris-connector/src/main/java/org/apache/doris/spark/DorisStreamLoad.java
##########
@@ -159,6 +160,25 @@ public void load(List<List<Object>> rows) throws
StreamLoadException {
String records = listToString(rows);
load(records);
}
+
+ public void loadV2(List<List<Object>> rows) throws StreamLoadException,
JsonProcessingException {
+ List<Map<Object,Object>> dataList = new ArrayList<>();
+ try {
+ for (List<Object> row : rows) {
+ Map<Object,Object> dataMap = new HashMap<>();
+ if (dfColumns.length == row.size()) {
+ for (int i = 0; i < dfColumns.length; i++) {
+ dataMap.put(dfColumns[i], row.get(i) == null ?
NULL_VALUE : row.get(i));
+ }
+ }
+ dataList.add(dataMap);
+ }
+ } catch (Exception e) {
+ throw new StreamLoadException("The number of configured columns
does not match the number of data columns.");
+ }
+ load((new ObjectMapper()).writeValueAsString(dataList));
+ }
+
Review comment:
It is recommended to add a unit test.
--
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]