メインコンテンツまでスキップ

別の Databricks ワークスペースでフェデレーション クエリを実行する

この記事では、レイクハウスフェデレーションを設定して、別のDatabricksワークスペースのDatabricksデータに対してフェデレーションクエリを実行する方法について説明します。レイクハウスフェデレーションの詳細については、「 レイクハウスフェデレーションとは」を参照してください。

important

Databricks-to-Databricks レイクハウスフェデレーションは、別の Databricks ワークスペースの Hive または AWS Glue メタストアによって管理されているデータに対してクエリを実行するための優れたツールです。 他のほとんどのシナリオでは、他の Databricks ワークフローの方が効率的です。

  • Databricksワークスペースが同じUnity Catalogメタストアを共有している場合は、標準のUnity Catalogクエリとデータガバナンスツールを使用して、ワークスペース間のクエリを管理できます。
  • Databricks アカウント内であるかどうかにかかわらず、別の Unity Catalog メタストアにアタッチされた Databricks ワークスペース内のデータに 読み取り専用 アクセスが必要な場合は、Delta Sharing の方が適しています。

どちらのシナリオでも、レイクハウスフェデレーションを設定する必要はありません。

レイクハウスフェデレーションを使用して別のワークスペースの Databricks カタログに接続するには、 Databricks Unity Catalog メタストアに次のものを作成する必要があります。

  • ワークスペース内のクラスターSQL ウェアハウスまたは ウェアハウス。Databricks
  • クラスターまたはSQL ウェアハウスへの接続。
  • クラスターまたは SQLウェアハウスからアクセスできる他の Databricks カタログをミラーリングする Unity Catalog メタストア内の フォーリンカタログ で、 Unity Catalog クエリー構文ツールとデータガバナンスツールを使用してデータへの Databricks ユーザー アクセスを管理できます。

始める前に

ワークスペースの要件:

  • Unity Catalogのワークスペースが有効になっています。

コンピュートの要件:

  • コンピュート・リソースからターゲット・データベース・システムへのネットワーク接続。 「レイクハウスフェデレーションのネットワーキングに関する推奨事項」を参照してください。
  • Databricks コンピュートは、 Databricks Runtime 13.3 LTS 以上、 および標準 または 専用 アクセスモードを使用する必要があります。
  • SQLウェアハウスはProまたはServerlessで、2023.40以上を使用している必要があります。

必要な権限:

  • 接続を作成するには、メタストア管理者か、ワークスペースに接続されているUnity Catalogメタストアの CREATE CONNECTION 権限を持つユーザーである必要があります。
  • フォーリンカタログを作成するには、メタストアに対する CREATE CATALOG 権限を持ち、接続の所有者であるか、接続に対する CREATE FOREIGN CATALOG 権限を持っている必要があります。

追加の権限要件は、以下の各タスクベースのセクションに記載しています。

また、接続の構成に使用している ワークスペースにアクティブなクラスターSQL ウェアハウスまたは ウェアハウスが必要です。Databricks

接続を作成する

接続では、外部データベースシステムにアクセスするためのパスと認証情報を指定します。接続を作成するには、カタログエクスプローラーを使用するか、Databricksノートブックまたは Databricks SQLクエリーエディタで CREATE CONNECTION SQLコマンドを使用できます。

注記

Databricks REST API または Databricks CLI を使用して接続を作成することもできます。 POST /api/2.1/unity-catalog/connections を参照してください。 および Unity Catalog コマンド

必要な権限: メタストア管理者またはCREATE CONNECTION権限を持つユーザー。

  1. In your Databricks workspace, click Catalog icon Catalog.

  2. At the top of the Catalog pane, click the Add or plus icon Add icon and select Add a connection from the menu.

    Alternatively, from the Quick access page, click the External data > button, go to the Connections tab, and click Create connection.

  3. On the Connection basics page of the Set up connection wizard, enter a user-friendly Connection name.

  4. Select a Connection type of Databricks.

  5. (Optional) Add a comment.

  6. Click Next.

  7. On the Authentication page, enter the following connection properties for the other Databricks instance:

    • Host: Workspace instance name. To learn how to get the workspace instance name, see Get identifiers for workspace objects.
    • Personal access token: A Databricks personal access token that enables access to the target workspace.. To learn how to get a token, see Databricks personal access token authentication. For connections, Databricks recommends using a personal access token for a service principal.
    • HTTP path: The HTTP path for your SQL warehouse. To get the path, go to SQL > SQL Warehouses in the sidebar, select the SQL warehouse, go to the Connection details tab, and copy the value for HTTP path.
  8. Click Create connection.

  9. On the Catalog basics page, enter the catalog name in the other Databricks workspace that can be mapped to a catalog object in this metastore.

  10. (Optional) Click Test connection to confirm that it works.

  11. Click Create catalog.

  12. On the Access page, select the workspaces in which users can access the catalog you created. You can select All workspaces have access, or click Assign to workspaces, select the workspaces, and then click Assign.

  13. Change the Owner who will be able to manage access to all objects in the catalog. Start typing a principal in the text box, and then click the principal in the returned results.

  14. Grant Privileges on the catalog. Click Grant:

    1. Specify the Principals who will have access to objects in the catalog. Start typing a principal in the text box, and then click the principal in the returned results.
    2. Select the Privilege presets to grant to each principal. All account users are granted BROWSE by default.
      • Select Data Reader from the drop-down menu to grant read privileges on objects in the catalog.
      • Select Data Editor from the drop-down menu to grant read and modify privileges on objects in the catalog.
      • Manually select the privileges to grant.
    3. Click Grant.
  15. Click Next.

  16. On the Metadata page, specify tags key-value pairs. For more information, see Apply tags to Unity Catalog securable objects.

  17. (Optional) Add a comment.

  18. Click Save.

フォーリンカタログの作成

注記

UI を使用してデータソースへの接続を作成する場合は、フォーリンカタログの作成が含まれているため、この手順をスキップできます。

フォーリンカタログは、外部 Databricks ワークスペース内のカタログをミラーリングするため、その外部 Databricks カタログ内のデータへのアクセスを、独自の Workpsace のカタログであるかのように管理できます。 フォーリンカタログを作成するには、既に定義されている外部 Databricks ワークスペースへの接続を使用します。

フォーリンカタログを作成するには、Catalog ExplorerCREATE FOREIGN CATALOGSQL を使用するか、Databricks ノートブックまたは クエリDatabricks SQL エディターの コマンドを使用します。Databricks REST API または Databricks CLI を使用してカタログを作成することもできます。 POST /api/2.1/unity-catalog/catalogs を参照してください。 および Unity Catalog コマンド

必要な権限: メタストアの CREATE CATALOG 権限、接続の所有権または接続の CREATE FOREIGN CATALOG 権限。

  1. In your Databricks workspace, click Catalog icon Catalog to open Catalog Explorer.

  2. At the top of the Catalog pane, click the Add or plus icon Add icon and select Add a catalog from the menu.

    Alternatively, from the Quick access page, click the Catalogs button, and then click the Create catalog button.

  3. Follow the instructions for creating foreign catalogs in Create catalogs.

サポートされているプッシュダウン

次のプッシュダウンは、すべてのコンピュートでサポートされています。

  • フィルター
  • 予測
  • 上限
  • 関数: フィルター式のみがサポートされています (文字列関数、数学関数、データ関数、時刻関数、タイムスタンプ関数、および Alias、Cast、SortOrder などの他の関数)。

次のプッシュダウンは、 Databricks Runtime 13.3 LTS 以上および SQLウェアハウス コンピュートでサポートされています。

  • 集計
  • 次の Boolean 演算子: =、<、<=、>、>=、<=>
  • 次の数学関数 (ANSI が無効になっている場合はサポートされません): +、-、*、%、/
  • 次のその他の演算子: ^、|、~
  • ソート (制限付きで使用した場合)

次のプッシュダウンはサポートされていません。

  • テーブルのJOIN
  • Windows の機能