I am connecting to teradata from jupyter notebooks using teradatasql / PyTd. While executing a long running sql, I realized the sql is bad formatted and want to cancel the executing sql. The interrupt signel we are generating is being ignored by the python API and neither canceling the sql execution nor canceling the connection.
Can someone please help me with it?
# Teradata connection using teradatasql module con = teradatasql.connect(None, host='teradata.hostname', user='username', password='password') cursor = con.cursor()
# Long running sql query = """select count(*), key from database.table group by key;""" cursor.execute(query)
The Teradata SQL Driver for Python does not yet support asynchronous cancel of a long-running query.
As a workaround, you can abort the session that is executing the long-running query. Viewpoint can be used to abort a session, or the SYSLIB.AbortSessions function can be executed in a separate SQL session, assuming that you have the necessary permission for the SYSLIB.AbortSessions function.
For information about the SYSLIB.AbortSessions function, please refer to the Teradata Database Reference / Application Programming Reference book / Chapter 4: System PMPC APIs / section AbortSessions. All Teradata Database documentation is available at www.info.teradata.com