Inconsistent behavior listing schemas in UC catalogs depending on quoting

Open
#245 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, sql
Domain
databases

Research direction

Start by reproducing the issue with the Python example and inspect the cursor.schemas API entry point. Compare the results for schemas('dev') and schemas('dev') against the catalog containing default and my_schema; done means both forms return the same schema rows, including global_temp.

Written by the indexing model from the issue text.

Description

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

Dominant language
Python
Stars
233
Forks
152
Avg merge
21h 5m
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databricks/databricks-sql-python

All issues in databricks/databricks-sql-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.