Pārlūkot izejas kodu

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

Romain Rigaux 5 gadi atpakaļ
vecāks
revīzija
78bffcf736
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. 4 1
      desktop/libs/kafka/src/kafka/ksql_client.py

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

@@ -146,7 +146,10 @@ class KSqlApi(object):
             line = line.strip()
 
           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':
               raise KSqlApiException(data_line['message'])
             if data_line['row']:  # If limit not reached