Making py connector to raise an error for wrong SQL when asking to plan a query

624398
New Contributor III

Hey all,

My aim is to validate a given SQL string without actually running it.

I thought I could use the `EXPLAIN` statement to do so.

So I tried using the `databricks-sql-connector` for python to explain a query, and so determine whether it's valid or not. Example python code:

```

import databricks.sql

with databricks.sql.connect(...) as connection:

with connection.cursor() as cursor:

cursor.execute("EXPLAIN SELECT BAD-QUERY AS FOO")

r = cursor.fetchall()

```

The problem with that implementation is that the driver does not throws an error, but instead retrieves me a string containing the error details.

Why it's a problem? I need to parse the string result to distinguish if the explained query was valid or not.

So I was wondering if there some kind of setting / parameter / configuration or so I can use to change the described above result.

Many thanks in Advance!