@@ -219,6 +219,11 @@ def _run_query(self, query):
219219 }
220220 output ["exception" ] = f"ERROR: { json .dumps (error_details )} "
221221
222+ # output = {'data': <stdout str>, 'error': <stderr str>, 'exception': <exception as a json string> }
223+ # for a statement you would expect 'error' to exist
224+ # for a query you would expect 'data' to exist
225+ # 'exception' in output indicates an error occurred during the execution (statement or query)
226+
222227 return output
223228
224229 def __init__ (self ,
@@ -482,6 +487,9 @@ def executeStmt(self, query):
482487 else :
483488 return result
484489 else :
490+ # returns either...
491+ # {'error': '<error message>'} if something went wrong; or
492+ # {'message': '<message>'} if the statement was executed successfully
485493 result = self ._run_query (query )
486494 if "exception" in result :
487495 return {"error" : result ["exception" ]}
@@ -494,7 +502,7 @@ def executeStmt(self, query):
494502 elif self .output == 'csv' :
495503 return message
496504 else :
497- return [ {'message' : message }]
505+ return {'message' : message }
498506
499507 def execute (self , query , suppress_errors = True ):
500508 """
@@ -508,7 +516,7 @@ def execute(self, query, suppress_errors=True):
508516 suppress_errors (bool, optional): If set to True, the method will return an empty list if an error occurs.
509517
510518 Returns:
511- dict, pd.DataFrame, or str: The output of the query, which can be a dictionary, a Pandas DataFrame,
519+ list( dict) , pd.DataFrame, or str: The output of the query, which can be a list of dictionary objects , a Pandas DataFrame,
512520 or a raw CSV string, depending on the configured output format.
513521
514522 Raises:
@@ -534,6 +542,10 @@ def execute(self, query, suppress_errors=True):
534542 else : # Assume 'dict' output
535543 return result
536544 else :
545+ # returns either...
546+ # {'error': <error json str>} if something went wrong; or
547+ # [{<data>}] if the statement was executed successfully, messages to stderr are ignored
548+
537549 output = self ._run_query (query )
538550 if "exception" in output :
539551 return {"error" : output ["exception" ]}
0 commit comments