Skip to content

Inconsistent behavior listing schemas in UC catalogs depending on quoting #245

Not planned

Description

@tom-rb

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 databricks/dbt-databricks#464

Activity

  1. cathleeny commented on Dec 3, 2026

    @cathleeny
    Collaborator

    This one isn't a bug. Metadata methods like cursor.schemas(...) take the plain stored name, not a SQL identifier, so backticks count as part of the name. Pass catalog_name="dev" rather than catalog_name="`dev`".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions