Эх сурвалжийг харах

[ksql] Do not error when single column record not in json

Romain Rigaux 5 жил өмнө
parent
commit
78bffcf736

+ 4 - 1
desktop/libs/kafka/src/kafka/ksql_client.py

@@ -146,7 +146,10 @@ class KSqlApi(object):
             line = line.strip()
             line = line.strip()
 
 
           if is_select:
           if is_select:
-            data_line = json.loads(line)
+            try:
+              data_line = json.loads(line)
+            except ValueError as e:
+              data_line = json.loads(line[:-1])  # Most probably record is not JSON
             if data_line.get('@type') == 'statement_error':
             if data_line.get('@type') == 'statement_error':
               raise KSqlApiException(data_line['message'])
               raise KSqlApiException(data_line['message'])
             if data_line['row']:  # If limit not reached
             if data_line['row']:  # If limit not reached