ksql-python
ksql-python copied to clipboard
IndexError after inserting
i'm receiving the following error after inserting into a stream using
client.ksql("INSERT INTO riderLocations (profileId, latitude, longitude) VALUES ('4ab5cbad', 37.3952, -122.0813);")`
Traceback (most recent call last):
File "
Although the insert is successful and I can view it on a select query, any ideas about what's causing it to throw an error?
@agmo1993 Thank you for reporting issue. I will check the API response.
Indeed, I see the same.
Seems like we get []
Not sure if it is the best way to fix it but it avoids it
https://github.com/bryanyang0528/ksql-python/pull/88
@romainr Thank you for fixing it. Good contribution!
@agmo1993 Please try if this fixes this issue. Thank you.
I had the same issue and this solved it. When do you think will this be released?
While we are waiting, I make this local correction :wink: :
class KsqlApiCustom(KSQLAPI):
def __init__(self, url, max_retries=3, check_version=True, **kwargs):
super().__init__(url, max_retries=max_retries,
check_version=check_version, **kwargs)
self.sa._raise_for_status = self._raise_for_status
@staticmethod
def _raise_for_status(r, response):
r_json = json.loads(response)
if r.getcode() != 200:
# seems to be the new API behavior
if r_json.get("@type") == "statement_error" or r_json.get("@type") == "generic_error":
error_message = r_json["message"]
error_code = r_json["error_code"]
stackTrace = r_json["stack_trace"]
raise KSQLError(error_message, error_code, stackTrace)
else:
raise KSQLError("Unknown Error: {}".format(r.content))
else:
# seems to be the old API behavior, so some errors have status 200, bug??
if r_json and r_json[0]["@type"] == "currentStatus" and r_json[0]["commandStatus"]["status"] == "ERROR":
error_message = r_json[0]["commandStatus"]["message"]
error_code = None
stackTrace = None
raise KSQLError(error_message, error_code, stackTrace)
return True
should be seeing a new release relatively soon. @bryanyang0528 is hard at work on updating the project. thanks for your patience.
Thank you @ozair-junior !!!