databricks-sql-python
databricks-sql-python copied to clipboard
Inconsistent behavior listing schemas in UC catalogs depending on quoting
With a dev catalog containing default and my_schema schemas, I get different results depending on the name quoting:
import os
from databricks import sql
host = os.getenv("DATABRICKS_HOST")
http_path = os.getenv("DATABRICKS_HTTP_PATH")
access_token = os.getenv("DATABRICKS_TOKEN")
connection = sql.connect(
server_hostname=host,
http_path=http_path,
access_token=access_token)
cursor = connection.cursor()
print("> schemas('`dev`')")
cursor.schemas('`dev`') # quoted name, I get (global_temp) only
result = cursor.fetchall()
for row in result:
print(row)
print("> schemas('dev')")
cursor.schemas('dev') # unquoted name, I get (default, my_schema, global_temp)
result = cursor.fetchall()
for row in result:
print(row)
cursor.close()
connection.close()
I'd expect the same behavior for both, since this is what dbt-databricks is apparently expecting too.
A unwanted side effect for dbt-databricks is https://github.com/databricks/dbt-databricks/issues/464