Connection without specifying catalog name in connection string causes an error

オープン
#305 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python, sql
領域
databases

調査の方向性

src/databricks/sqlalchemy/base.py の278行目付近から始め、接続文字列でカタログが省略されている場合に get_table_names がカタログをどのように処理するかを追跡してください。スキーマと明示的なカタログを指定して SHOW VIEWS の失敗を再現し、その後、メタデータ検査で None カタログを生成せずにそのカタログを対象にできることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

bug sqlalchemy

Hello,
I'm trying to create an engine connection which could manage multiple catalogs at once

connection_uri = "databricks://token:XXXXXX@DB_HOST?http_path=/sql/1.0/warehouses/DWH_ID"
engine = create_engine(connection_uri, future=True)
meta_inspector = inspect(self.engine)

Later when calling for example
tables = meta_inspector.get_table_names('test_schema')
I get the following error

backend-1  | sqlalchemy.exc.DatabaseError: (databricks.sql.exc.ServerOperationError) Fail to execute the command as the target schema `None.test_schema` is not in the current catalog. Please set the current catalog with 'USE CATALOG None' first.
backend-1  | [SQL: SHOW VIEWS FROM `None`.`test_schema`]

After further inspection I found the current method being called:
https://github.com/databricks/databricks-sql-python/blob/62eb1d407ab03fc2c57a6626bec2173dbdd8bbb3/src/databricks/sqlalchemy/base.py#L278

It could be fixed with adding on Line 278 the following:
_target_catalog = kwags.get("catalog") or self.catalog
and referencing the catalog name in the method get_table_names
tables = meta_inspector.get_table_names(schema='test_schema',catalog='test_catalog')

NOTE : I'm avoiding creating a different engine for every catalog due to slow response from Databricks
I'm hesitant in opening a PR for this as it's not well tested and I'm not sure if there is an alternative to what i'm trying to achieve , so any feedback would be great !

主要言語
Python
スター
233
フォーク
152
平均マージ
21時間 5分
マージ済み PR(30日)
10

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

databricks/databricks-sql-python のほかの issue

databricks/databricks-sql-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。