Reamer commented on code in PR #4675:
URL: https://github.com/apache/zeppelin/pull/4675#discussion_r1361667422


##########
livy/src/main/java/org/apache/zeppelin/livy/LivySparkSQLInterpreter.java:
##########
@@ -180,26 +181,50 @@ protected List<String> parseSQLJsonOutput(String output) {
     List<String> rows = new ArrayList<>();
 
     String[] rowsOutput = output.split("(?<!\\\\)\\n");
+
+    if (rowsOutput.length < 2){
+      return Arrays.asList(rowsOutput);
+    }
+
     String[] header = rowsOutput[1].split("\t");
     List<String> cells = new ArrayList<>(Arrays.asList(header));
     rows.add(StringUtils.join(cells, "\t"));
 
     for (int i = 2; i < rowsOutput.length; i++) {
-      Map<String, String> retMap = new Gson().fromJson(
-          rowsOutput[i], new TypeToken<HashMap<String, String>>() {
-          }.getType()
-      );
+      // one-by-one serialization to handle the case when
+      // the value is non-primitive such as: {"lang": ["java", "NodeJS"]}.
+      Map<String, String> retMap = serialize(rowsOutput[i]);
+
       cells = new ArrayList<>();
       for (String s : header) {
         cells.add(retMap.getOrDefault(s, "null")
             .replace("\n", "\\n")
             .replace("\t", "\\t"));
       }
       rows.add(StringUtils.join(cells, "\t"));
+
     }
     return rows;
   }
 
+  private Map<String, String> deserialize(String jsonString) {
+    Map<String, String> map = new HashMap<>();
+    Gson gson = new Gson();
+    JsonElement jsonElement = gson.fromJson(jsonString, JsonElement.class);
+    JsonObject jsonObject = jsonElement.getAsJsonObject();
+    for (String key : jsonObject.keySet()) {

Review Comment:
   Please iterate over the entrySet.
   See https://rules.sonarsource.com/java/RSPEC-2864/



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

Reply via email to