Delta Sharing の共有を作成して管理する
この記事では、Delta Sharing の共有を作成および管理する方法について説明します。
共有は、Unity Catalog のセキュリティ保護可能なオブジェクトであり、次のデータ資産を 1 人以上の受信者と共有するために使用できます。
- テーブルとテーブルパーティション
- ビュー (行レベルと列レベルでアクセスを制限する動的ビューを含む)
- ボリューム
- ノートブック
- AIモデル
スキーマ (データベース) 全体を共有すると、受信者は共有した時点でスキーマ内のすべてのテーブル、ビュー、モデル、ボリュームにアクセスできるほか、今後スキーマに追加されたデータや AI アセットにもアクセスできます。
共有には、1 つの Unity Catalog メタストアからのデータと AI アセットのみを含めることができます。 データ資産と AI 資産は、いつでも共有に追加したり、共有から削除したりできます。
詳細については 、「共有、プロバイダー、および受信者」を参照してください。
必要条件
共有を作成するには、次のことを行う必要があります。
- メタストア管理者であるか、共有するデータが登録されている Unity Catalog メタストアの
CREATE SHARE
特権を持っている。 - その Unity Catalog メタストアがアタッチされている Databricks ワークスペースを使用して共有を作成します。
共有にテーブルまたはビューを追加するには、次の操作を行う必要があります。
- 共有の所有者になります。
- テーブルまたはビューを含むカタログとスキーマに対する
USE CATALOG
権限とUSE SCHEMA
権限、またはカタログまたはスキーマの所有権を持っている。 - テーブルまたはビューに対する
SELECT
権限を持っている。 テーブルまたはビューを引き続き共有するには、その権限を保持する必要があります。 これを紛失すると、受信者は共有を通じてテーブルにアクセスしたり、ビューを表示したりできなくなります。 そのため、Databricks では、共有所有者としてグループを使用することをお勧めします。
共有にボリュームを追加するには、次の操作を行う必要があります。
- 共有の所有者になります。
- カタログまたはスキーマのボリュームまたは所有権を含むカタログおよびスキーマに対する
USE CATALOG
権限とUSE SCHEMA
権限を持っている。 - ボリュームの
READ VOLUME
権限を持っています。 ボリュームを引き続き共有するには、その権限を維持する必要があります。 紛失した場合、受信者は共有からボリュームにアクセスできなくなります。 そのため、Databricks では、共有所有者としてグループを使用することをお勧めします。
共有にモデルを追加するには、次の操作を行う必要があります。
- 共有の所有者になります。
- モデルを含むカタログとスキーマに対する
USE CATALOG
権限とUSE SCHEMA
権限を持っているか、カタログまたはスキーマの所有権を持っている。 - モデルの
EXECUTE
権限を持っています。 モデルを引き続き共有するには、その権限を保持する必要があります。 紛失した場合、受信者は共有を介してモデルにアクセスできなくなります。 そのため、Databricks では、共有所有者としてグループを使用することをお勧めします。
スキーマ全体を共有するには、次の操作を行う必要があります。
- 共有とスキーマの所有者であるか、右の権限を持っている
USE SCHEMA.
- テーブルを共有するスキーマに対する
SELECT
権限がある。 - ボリュームを共有するスキーマに対する
READ VOLUME
権限がある。
ノートブック ファイルを共有に追加するには、次の条件を満たしている必要があります。
- 共有の所有者であり、ノートブックに対する CAN READ アクセス許可を持っている。
受信者に共有へのアクセス権を付与するには、次のいずれかである必要があります。
- メタストア管理者。
- 共有オブジェクトと受信者オブジェクト (
USE SHARE
+SET SHARE PERMISSION
) または共有の所有者) および (USE RECIPIENT
または受信者の所有者) の両方に対する委任されたアクセス許可または所有権を持つユーザー。
共有を表示するには、次のいずれかである必要があります。
- メタストアの管理者(すべてを表示できる)
USE SHARE
権限を持つユーザー (すべて閲覧可能)- シェアオブジェクトの所有者
コンピュートの要件:
- Databricks ノートブックを使用して共有を作成する場合、コンピュート リソースは Databricks Runtime 11.3 LTS 以上を使用し、標準または専用アクセス モード (以前の共有およびシングル ユーザー) を持っている必要があります。
- SQLステートメントを使用して共有にスキーマを追加する場合 (またはスキーマを更新または削除する場合)、 Databricks Runtime 13.3 LTS以上を実行している SQL ウェアハウスまたはコンピュートを使用する必要があります。 Catalog Explorer を使用して同じことを実行する場合、コンピュートの要件はありません。
共有オブジェクトを作成してください
共有を作成するには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの CREATE SHARE
SQL コマンドを使用できます。
必要な権限 :メタストアの管理者またはメタストアの CREATE SHARE
権限を持つユーザー。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, click the Share data button.
-
On the Create share page, enter the share Name and an optional comment.
-
Click Save and continue.
You can continue to add data assets, or you can stop and come back later.
-
On the Add data assets tab, select the tables, volumes, views, and models you want to share.
For detailed instructions, see:
-
Click Save and continue.
-
On the Add notebooks tab, select the notebooks you want to share.
For detailed instructions, see Add notebook files to a share.
-
Click Save and continue.
-
On the Add recipients tab, select the recipients you want to share with.
For detailed instructions, see Manage access to Delta Sharing data shares (for providers).
-
Click Share data to share the data with the recipients.
Run the following command in a notebook or the Databricks SQL query editor:
CREATE SHARE [IF NOT EXISTS] <share-name>
[COMMENT "<comment>"];
Now you can add tables, volumes, views, and models to the share.
For detailed instructions, see:
Run the following command using the Databricks CLI.
databricks shares create <share-name>
You can use --comment
to add a comment or --json
to add assets to the share. For details, see the sections that follow.
Now you can add tables, volumes, views, and models to the share.
For detailed instructions, see:
共有にテーブルを追加する
共有にテーブルを追加するには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの SQL コマンドを使用できます。
テーブルコメント、列コメント、 および主キー制約 は、2024 年 7 月 25 日以降に Databricks-to-Databricks 共有を使用して受信者と共有される共有に含まれます。 リリース日より前に受信者と共有された共有を通じてコメントと制約の共有を開始する場合は、コメントと制約の共有をトリガーするために、受信者のアクセス権を取り消して再付与する必要があります。
必要な権限 : 共有オブジェクトの所有者、テーブルを含むカタログとスキーマの USE CATALOG
と USE SCHEMA
、およびテーブルに対する SELECT
権限。 テーブルを共有する限り、 SELECT
権限を維持する必要があります。 詳細については、「 要件」を参照してください。
ワークスペース管理者であり、テーブルを含むスキーマとカタログに対する USE SCHEMA
および USE CATALOG
のアクセス許可をワークスペース管理者グループから継承した場合、テーブルを共有に追加することはできません。 まず、スキーマとカタログに対する USE SCHEMA
権限と USE CATALOG
権限を自分自身に付与する必要があります。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find the share you want to add a table to and click its name.
-
Click Manage assets > Add data assets.
-
On the Add tables page, select either an entire schema (database) or individual tables and views.
-
To select a table or view, first select the catalog, then the schema that contains the table or view, then the table or view itself.
You can search for tables by name, column name, or comment using workspace search. See Search for workspace objects.
-
To select a schema, first select the catalog and then the schema.
For detailed information about sharing schemas, see Add schemas to a share.
-
-
History: Share the table history to allow recipients to perform time travel queries or read the table with Spark Structured Streaming. For Databricks-to-Databricks shares, the table’s Delta log is also shared to improve performance. See Improve table read performance with history sharing. History sharing requires Databricks Runtime 12.2 LTS or above.
If, in addition to doing time travel queries and streaming reads, you want your customers to be able to query a table’s change data feed (CDF) using the table_changes() function, you must enable CDF on the table before you share it WITH HISTORY
.
- (Optional) Click Advanced table options to specify the following options. Alias and partitions are not available if you select an entire schema. Table history is included by default if you select an entire schema.
- Alias: An alternate table name to make the table name more readable. The alias is the table name that the recipient sees and must use in queries. Recipients cannot use the actual table name if an alias is specified.
- Partition: Share only part of the table. For example,
(column = 'value')
. See Specify table partitions to share and Use recipient properties to do partition filtering.
- Click Save.
Run the following command in a notebook or the Databricks SQL query editor to add a table:
ALTER SHARE <share-name> ADD TABLE <catalog-name>.<schema-name>.<table-name> [COMMENT "<comment>"]
[PARTITION(<clause>)] [AS <alias>]
[WITH HISTORY | WITHOUT HISTORY];
Run the following to add an entire schema. The ADD SCHEMA
command requires a SQL warehouse or compute running Databricks Runtime 13.3 LTS or above. For detailed information about sharing schemas, see Add schemas to a share.
ALTER SHARE <share-name> ADD SCHEMA <catalog-name>.<schema-name>
[COMMENT "<comment>"];
Options include the following. PARTITION
and AS <alias>
are not available if you select an entire schema.
-
PARTITION(<clause>)
: If you want to share only part of the table, you can specify a partition. For example,(column = 'value')
See Specify table partitions to share and Use recipient properties to do partition filtering. -
AS <alias>
: An alternate table name, or Alias to make the table name more readable. The alias is the table name that the recipient sees and must use in queries. Recipients cannot use the actual table name if an alias is specified. Use the format<schema-name>.<table-name>
. -
WITH HISTORY
orWITHOUT HISTORY
: WhenWITH HISTORY
is specified, share the table with full history, allowing recipients to perform time travel queries and streaming reads. For Databricks-to-Databricks shares, history sharing also shares the table’s Delta log to improve performance. The default behavior for table sharing isWITH HISTORY
if your compute is running Databricks Runtime 16.2 or above andWITHOUT HISTORY
for earlier Databricks Runtime versions. For schema sharing, the default isWITH HISTORY
regardless of Databricks Runtime version.WITH HISTORY
andWITHOUT HISTORY
require Databricks Runtime 12.2 LTS or above. See also Improve table read performance with history sharing.
If, in addition to doing time travel queries and streaming reads, you want your customers to be able to query a table’s change data feed (CDF) using the table_changes() function, you must enable CDF on the table before you share it WITH HISTORY
.
For more information about ALTER SHARE
options, see ALTER SHARE.
To add a table, run the following command using the Databricks CLI.
databricks shares update <share-name> \
--json '{
"updates": [
{
"action": "ADD",
"data_object": {
"name": "<table-full-name>",
"data_object_type": "TABLE",
"shared_as": "<table-alias>"
}
}
]
}'
To add a schema, run the following Databricks CLI command:
databricks shares update <share-name> \
--json '{
"updates": [
{
"action": "ADD",
"data_object": {
"name": "<schema-full-name>",
"data_object_type": "SCHEMA"
}
}
]
}'
For tables, and only tables, you can omit "data_object_type"
.
To learn about the options listed in this example, view the instructions on the SQL tab.
To learn about additional parameters, run databricks shares update --help
or see PATCH /api/2.1/unity-catalog/shares/ in the REST API reference.
共有からテーブルを削除する方法については、「 共有の更新」を参照してください。
共有するテーブルパーティションの指定
テーブルを共有に追加するときにテーブルの一部のみを共有するには、パーティション仕様を指定できます。 パーティションは、共有にテーブルを追加するとき、または共有を更新するときに、Catalog Explorer、DatabricksUnity CatalogCLI 、またはSQL Databricksノートブックの コマンド、またはDatabricks SQL クエリ エディターを使用して指定できます。「共有にテーブルを追加する」および「共有を更新する」を参照してください。
基本的な例
次の SQL の例では、 inventory
テーブルのデータの一部を共有し、 year
、 month
、 date
の各カラムでパーティション化されています。
- 2021年のデータ。
- 2020年12月のデータ。
- 2019年12月25日のデータ。
ALTER SHARE share_name
ADD TABLE inventory
PARTITION (year = "2021"),
(year = "2020", month = "Dec"),
(year = "2019", month = "Dec", date = "2019-12-25");
受信者のプロパティを使用してパーティションフィルタリングを行います
データ受信者のプロパティに一致するテーブルパーティションを共有できます (パラメータ化されたパーティション共有とも呼ばれます)。
デフォルトのプロパティには、次のものが含まれます。
databricks.accountId
:データ受信者が所属する Databricks アカウント(Databricks-to-Databricks 共有のみ)。databricks.metastoreId
: データ受信者が属する Unity Catalog メタストア (Databricks間共有のみ)。databricks.name
: データ受信者の名前。
受信者を作成または更新するときに、任意のカスタムプロパティを作成できます。
受信者プロパティによるフィルター処理を使用すると、複数の Databricks アカウント、ワークスペース、およびユーザー間で同じ共有を使用して同じテーブルを共有できますが、それらの間のデータ境界は維持されます。
たとえば、テーブルに Databricks アカウント ID 列が含まれている場合は、Databricks アカウント ID で定義されたテーブルパーティションを持つ 1 つの共有を作成できます。 共有すると、Delta Sharing は、各受信者に Databricks アカウントに関連付けられているデータのみを動的に配信します。
プロパティごとに動的にパーティション分割する機能がなければ、受信者ごとに個別の共有を作成する必要があります。
共有を作成または更新するときに受信者のプロパティでフィルター処理するパーティションを指定するには、カタログ エクスプローラーを使用するか、Databricks ノートブックまたは Databricks SQL クエリ エディターの CURRENT_RECIPIENT
SQL 関数を使用できます。
受信者のプロパティは、Databricks Runtime 12.2 以降で使用できます。
- Catalog Explorer
- SQL
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find the share you want to update and click its name.
-
Click Manage assets > Add data assets.
-
On the Add tables page, select the catalog and database that contain the table, then select the table.
If you aren’t sure which catalog and database contain the table, you can search for it by name, column name, or comment using workspace search. See Search for workspace objects.
-
(Optional) Click Advanced table options to add Partition specifications.
On the Add partition to a table dialog, add the property-based partition specification using the following syntax:
(<column-name> = CURRENT_RECIPIENT().<property-key>)
For example,
(country = CURRENT_RECIPIENT().'country')
-
Click Save.
Run the following command in a notebook or the Databricks SQL query editor:
ALTER SHARE <share-name> ADD TABLE <catalog-name>.<schema-name>.<table-name>
PARTITION (<column-name> = CURRENT_RECIPIENT().<property-key>);
For example,
ALTER SHARE acme ADD TABLE acme.default.some_table
PARTITION (country = CURRENT_RECIPIENT().'country');
削除ベクトルまたは列マッピングを含むテーブルを共有に追加する
プレビュー
この機能は パブリック プレビュー段階です。
削除ベクトルは、Delta テーブルで有効にできるストレージ最適化機能です。 削除ベクトルとはを参照してください。
Databricks では、Delta テーブルの列マッピングもサポートされています。 「Delta Lake 列マッピングを使用した列の名前変更と削除」を参照してください。
削除ベクトルまたは列マッピングを使用してテーブルを共有するには、履歴と共有する必要があります。 「共有にテーブルを追加する」を参照してください。
削除ベクトルまたは列マッピングを使用してテーブルを共有すると、受信者は SQLウェアハウス、 Databricks Runtime 14.1 以降を実行しているコンピュート、またはオープンソース delta-sharing-spark
3.1 以上を実行しているコンピュートを使用してテーブルをクエリできます。 削除ベクトルまたは列マッピングが有効になっているテーブルの読み取りおよび削除ベクトルまたは列マッピングが有効になっているテーブルの読み取りを参照してください。
共有にビューを追加する
プレビュー
この機能は パブリック プレビュー段階です。
ビューは、1 つ以上のテーブルまたは他のビューから作成される読み取り専用オブジェクトです。 ビューは、Unity Catalog メタストア内の複数のスキーマとカタログに含まれるテーブルやその他のビューから作成できます。 「ビューの作成と管理」を参照してください。
このセクションでは、カタログ エクスプローラー、Databricks CLI、または Databricks ノートブックまたは Databricks SQL クエリ エディターの SQL コマンドを使用して、共有にビューを追加する方法について説明します。 Unity Catalog REST API を使用する場合は、REST API リファレンスの PATCH /api/2.1/unity-catalog/shares/ を参照してください。
必要な権限 :共有オブジェクトの所有者、ビューを含むカタログとスキーマの USE CATALOG
と USE SCHEMA
、ビューの SELECT
。 意見を共有したい限り SELECT
権限を維持する必要があります。 詳細については、「 要件」を参照してください。
追加要件 :
- ワークフロー、ノートブック、DLTのサーバレス コンピュート は、ビュー共有を設定しているアカウントで有効にする必要があります。Enable サーバレス コンピュートを参照してください。
- 共有可能なビューは、Delta テーブルまたはその他の共有可能なビューで定義する必要があります。
- 共有テーブルまたは共有ビューを参照するビューは共有できません。
- SQL共有にビューを追加するときは、Databricks Runtime 13.3LTS 以上で ウェアハウスまたはコンピュートを使用する必要があります。
- 受信者がビューを使用する際の要件と制限については、「共有ビューを読む」を参照してください。
共有にビューを追加するには:
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find the share you want to add a view to and click its name.
-
Click Manage assets > Add data assets.
-
On the Add tables page, search or browse for the view that you want to share and select it.
-
(Optional) Click Advanced table options to specify an Alias, or alternate view name, to make the view name more readable. The alias is the name that the recipient sees and must use in queries. Recipients cannot use the actual view name if an alias is specified.
-
Click Save.
Run the following command in a notebook or the Databricks SQL query editor:
ALTER SHARE <share-name> ADD VIEW <catalog-name>.<schema-name>.<view-name>
[COMMENT "<comment>"]
[AS <alias>];
Options include:
AS <alias>
: An alternate view name, or alias, to make the view name more readable. The alias is the view name that the recipient sees and must use in queries. Recipients cannot use the actual view name if an alias is specified. Use the format<schema-name>.<view-name>
.COMMENT "<comment>"
: Comments appear in the Catalog Explorer UI and when you list and display view details using SQL statements.
For more information about ALTER SHARE
options, see ALTER SHARE.
Run the following Databricks CLI command:
databricks shares update <share-name> \
--json '{
"updates": [
{
"action": "ADD",
"data_object": {
"name": "<view-full-name>",
"data_object_type": "VIEW",
"shared_as": "<view-alias>"
}
}
]
}'
"shared_as": "<view-alias>"
is optional and provides an alternate view name, or alias, to make the view name more readable. The alias is the view name that the recipient sees and must use in queries. Recipients cannot use the actual view name if an alias is specified. Use the format <schema-name>.<view-name>
.
To learn about additional parameters, run databricks shares update --help
or see PATCH /api/2.1/unity-catalog/shares/ in the REST API reference.
共有からビューを削除する方法については、「 共有の更新」を参照してください。
動的ビューを共有に追加して行と列をフィルター処理する
プレビュー
この機能は パブリック プレビュー段階です。
ダイナミックビューを使用して、次のようなテーブルデータへのきめ細かなアクセス制御を設定できます。
- 列または行のレベルでのセキュリティ。
- データマスキング。
CURRENT_RECIPIENT() 関数を使用する動的ビューを作成する場合は、受信者定義で指定したプロパティに従って受信者のアクセスを制限できます。
このセクションでは、動的ビューを使用して、行レベルと列レベルの両方でテーブルデータへの受信者のアクセスを制限する例を示します。
必要条件
-
Databricks Runtime バージョン :
CURRENT_RECIPIENT
関数は、Databricks Runtime 14.2 以降でサポートされています。 -
権限 :
- ビューを作成するには、共有オブジェクトの所有者であること、ビューを含むカタログとスキーマに
USE CATALOG
とUSE SCHEMA
があり、ビューにSELECT
が必要です。 意見を共有したい限りSELECT
権限を維持する必要があります。 - 受信者のプロパティを設定するには、受信者オブジェクトの所有者である必要があります。
- ビューを作成するには、共有オブジェクトの所有者であること、ビューを含むカタログとスキーマに
-
制限事項 : ビュー共有に関するすべての制限事項 ( Databricks-to-Databricks 共有の制限を含む) に加えて、次の制限があります。
- プロバイダーが
CURRENT_RECIPIENT
関数を使用するビューを共有する場合、プロバイダーは共有コンテキストのためにビューに対して直接クエリを実行できません。 このような動的ビューをテストするには、プロバイダーがビューを自分自身と共有し、受信者としてビューに対してクエリを実行する必要があります。 - プロバイダーは、動的ビューを参照するビューを作成できません。
- プロバイダーが
受取人のプロパティを設定する
これらの例では、共有するテーブルに country
という名前の列があり、一致する country
プロパティを持つ受信者のみが特定の行または列を表示できます。
受信者のプロパティは、カタログ エクスプローラーまたは Databricks ノートブックまたは SQL クエリ エディターの SQL コマンドを使用して設定できます。
- Catalog Explorer
- SQL
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Recipients tab, find the recipient you want to add the properties to and click its name.
-
Click Edit properties.
-
On the Edit recipient properties dialog, enter the column name as a key (in this case
country
) and the value you want to filter by as the value (for example,CA
). -
Click Save.
To set the property on the recipient, use ALTER RECIPIENT
. In this example, the country
property is set to CA
.
ALTER RECIPIENT recipient1 SET PROPERTIES ('country' = 'CA');
受信者に行レベルの権限を持つダイナミックビューを作成してください
この例では、country
プロパティが一致する受信者のみが特定の行を表示できます。
CREATE VIEW my_catalog.default.view1 AS
SELECT * FROM my_catalog.default.my_table
WHERE country = CURRENT_RECIPIENT('country');
もう1つの選択肢は、データプロバイダーがファクトテーブルのフィールドを受信者のプロパティにマッピングする個別のマッピングテーブルを維持することです。これにより、受信者のプロパティとファクトテーブルのフィールドを分離して柔軟性を高めることができます。
受信者用に列レベルの権限を持つダイナミックビューを作成してください
この例では、country
プロパティに一致する受信者だけが特定の列を表示できます。 他のユーザーには、返されたデータが次のように表示されます REDACTED
。
CREATE VIEW my_catalog.default.view2 AS
SELECT
CASE
WHEN CURRENT_RECIPIENT('country') = 'US' THEN pii
ELSE 'REDACTED'
END AS pii
FROM my_catalog.default.my_table;
動的ビューを受信者と共有する
動的ビューを受信者と共有するには、標準ビューの場合と同じ SQL コマンドまたは UI プロシージャを使用します。 「共有にビューを追加する」を参照してください。
共有にボリュームを追加します
ボリュームは、クラウド オブジェクト ストレージの場所にあるストレージの論理ボリュームを表す Unity Catalog オブジェクトです。 これらは主に、表形式以外のデータ資産に対するガバナンスを提供することを目的としています。 Unity Catalogボリュームとはを参照してください。
このセクションでは、Catalog Explorer、Databricks CLI、または Databricks ノートブックまたは SQL クエリ エディターの SQL コマンドを使用して、共有にボリュームを追加する方法について説明します。 を使用したい場合は、Unity CatalogRESTAPI PATCHを参照してください。 /api/2.1/unity-catalog/shares / RESTAPIを参照してください。
ボリュームコメントは、2024年7月25日以降に Databricks-to-Databricks 共有を使用して受信者と共有される共有に含まれます。 リリース日より前に受信者と共有された共有を通じてコメントの共有を開始する場合、コメント共有をトリガーするには、受信者のアクセス権を取り消して再付与する必要があります。
必要な権限 : 共有オブジェクトの所有者、ボリュームを含むカタログとスキーマの USE CATALOG
と USE SCHEMA
、ボリュームの READ VOLUME
。 ボリュームを共有する限り、 READ VOLUME
特権を維持する必要があります。 詳細については、「 要件」を参照してください。
追加要件 :
- ボリューム共有は、 Databricks-to-Databricks 共有でのみサポートされます。
- 共有にボリュームを追加するときは、バージョン 2023.50 以降の SQLウェアハウス、または Databricks Runtime 14.1 以降のコンピュート リソースを使用する必要があります。
- プロバイダー側のボリュームストレージにカスタムネットワーク構成(ファイアウォールやプライベートリンクなど)がある場合、プロバイダーは、ボリュームのストレージ場所に接続できるように、受信者のコントロールプレーンとデータプレーンのアドレスが適切にホワイトリストに登録されていることを確認する必要があります。
共有にボリュームを追加するには、次のようにします。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find the share you want to add a volume to and click its name.
-
Click Manage assets > Edit assets.
-
On the Edit assets page, search or browse for the volume that you want to share and select it.
Alternatively, you can select the entire schema that contains the volume. See Add schemas to a share.
-
(Optional) Click Advanced options to specify an alternate volume name, or Alias, to make the volume name more readable.
Aliases are not available if you select an entire schema.
The alias is the name that the recipient sees and must use in queries. Recipients cannot use the actual volume name if an alias is specified.
-
Click Save.
Run the following command in a notebook or the Databricks SQL query editor:
ALTER SHARE <share-name> ADD VOLUME <catalog-name>.<schema-name>.<volume-name>
[COMMENT "<comment>"]
[AS <alias>];
Options include:
AS <alias>
: An alternate volume name, or alias, to make the volume name more readable. The alias is the volume name that the recipient sees and must use in queries. Recipients cannot use the actual volume name if an alias is specified. Use the format<schema-name>.<volume-name>
.COMMENT "<comment>"
: Comments appear in the Catalog Explorer UI and when you list and display volume details using SQL statements.
For more information about ALTER SHARE
options, see ALTER SHARE.
Run the following command using Databricks CLI 0.210 or above:
databricks shares update <share-name> \
--json '{
"updates": [
{
"action": "ADD",
"data_object": {
"name": "<volume-full-name>",
"data_object_type": "VOLUME",
"string_shared_as": "<volume-alias>"
}
}
]
}'
"string_shared_as": "<volume-alias>"
is optional and provides an alternate volume name, or alias, to make the volume name more readable. The alias is the volume name that the recipient sees and must use in queries. Recipients cannot use the actual volume name if an alias is specified. Use the format <schema-name>.<volume-name>
.
To learn about additional parameters, run databricks shares update --help
or see PATCH /api/2.1/unity-catalog/shares/ in the REST API reference.
共有からのボリュームの削除に関する情報については、「 共有の更新」を参照してください。
共有にモデルを追加する
このセクションでは、カタログ エクスプローラー、Databricks CLI、または Databricks ノートブックまたは SQL クエリ エディターの SQL コマンドを使用して、共有にモデルを追加する方法について説明します。 を使用したい場合は、Unity CatalogRESTAPI PATCHを参照してください。 /api/2.1/unity-catalog/shares / RESTAPIを参照してください。
モデル コメントとモデル バージョン コメントは、 Databricks-to-Databricks 共有を使用して共有される共有に含まれます。
必要な権限 : 共有オブジェクトの所有者、モデルを含むカタログとスキーマの USE CATALOG
と USE SCHEMA
、モデルの EXECUTE
。 モデルを共有する限り、 EXECUTE
権限を維持する必要があります。 詳細については、「 要件」を参照してください。
追加要件 :
- モデル共有は、 Databricks-to-Databricks 共有でのみサポートされます。
- 共有にモデルを追加するときは、バージョン 2023.50 以降の SQLウェアハウス、または Databricks Runtime 14.0 以降のコンピュート リソースを使用する必要があります。
共有にモデルを追加するには:
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find the share you want to add a model to and click its name.
-
Click Manage assets > Edit assets.
-
On the Edit assets page, search or browse for the model that you want to share and select it.
Alternatively, you can select the entire schema that contains the model. See Add schemas to a share.
-
(Optional) Click Advanced options to specify an alternate model name, or Alias, to make the model name more readable.
Aliases are not available if you select an entire schema.
The alias is the name that the recipient sees and must use in queries. Recipients cannot use the actual model name if an alias is specified.
-
Click Save.
Run the following command in a notebook or the Databricks SQL query editor:
ALTER SHARE <share-name> ADD MODEL <catalog-name>.<schema-name>.<model-name>
[COMMENT "<comment>"]
[AS <alias>];
Options include:
AS <alias>
: An alternate model name, or alias, to make the model name more readable. The alias is the model name that the recipient sees and must use in queries. Recipients cannot use the actual model name if an alias is specified. Use the format<schema-name>.<model-name>
.COMMENT "<comment>"
: Comments appear in the Catalog Explorer UI and when you list and display model details using SQL statements.
For more information about ALTER SHARE
options, see ALTER SHARE.
Run the following command using Databricks CLI 0.210 or above:
databricks shares update <share-name> \
--json '{
"updates": [
{
"action": "ADD",
"data_object": {
"name": "<model-full-name>",
"data_object_type": "MODEL",
"string_shared_as": "<model-alias>"
}
}
]
}'
"string_shared_as": "<model-alias>"
is optional and provides an alternate model name, or alias, to make the model name more readable. The alias is the model name that the recipient sees and must use in queries. Recipients cannot use the actual model name if an alias is specified. Use the format <schema-name>.<model-name>
.
To learn about additional parameters, run databricks shares update --help
or see PATCH /api/2.1/unity-catalog/shares/ in the REST API reference.
共有からモデルを削除する方法については、「 共有の更新」を参照してください。
共有にスキーマを追加する
スキーマ全体を共有に追加すると、受信者は、共有を作成した時点のスキーマ内のすべてのデータ資産だけでなく、時間の経過とともにスキーマに追加されるすべての資産にもアクセスできます。 これには、スキーマ内のすべてのテーブル、ビュー、およびボリュームが含まれます。 この方法で共有されたテーブルには、常に全履歴が含まれます。
SQLを使用してスキーマを追加、更新、または削除するには、 Databricks Runtime 13.3 LTS以上を実行している SQL ウェアハウスまたはクラスターが必要です。 Catalog Explorer を使用して同じことを実行する場合、コンピュートの要件はありません。
必要な権限 : 共有オブジェクトの所有者およびスキーマの所有者 (またはスキーマに対する USE SCHEMA
権限と SELECT
権限を持つユーザー)。
共有にスキーマを追加するには、「 共有にテーブルを追加する」の指示に従い、スキーマの追加方法を指定する内容に注意してください。
テーブル・エイリアス、パーティション、およびボリューム・エイリアスは、スキーマ全体を選択した場合は使用できません。 スキーマ内のアセットに対してエイリアスまたはパーティションを作成した場合、スキーマ全体を共有に追加すると、これらは削除されます。
スキーマ共有を使用して共有しているテーブルまたはボリュームの詳細オプションを指定する場合は、SQL を使用してテーブルまたはボリュームを共有し、テーブルまたはボリュームに別のスキーマ名のエイリアスを指定する必要があります。
ノートブック ファイルを共有に追加する
Catalog Explorer を使用して、ノートブック ファイルを共有に追加します。
必要なアクセス許可 : 共有オブジェクトの所有者と、共有するノートブックに対する CAN READ アクセス許可。
-
Databricks ワークスペースで、[
カタログ] をクリックします。
-
[クイック アクセス ] ページで、[ Delta Sharing] > ボタンをクリックします。
-
[ 自分が共有] タブで、ノートブックを追加する共有を見つけて、その名前をクリックします。
-
[ アセットの管理 ] をクリックし、[ ノートブック ファイルの追加 ] を選択します。
-
[ ノートブック ファイルの追加 ] ページで、ファイル アイコンをクリックして、共有するノートブックを参照します。
- 共有したいファイルをクリックして、「 選択 」をクリックします。
- (必要に応じて) [ 共有形式 ] フィールドにファイルのわかりやすいエイリアスを指定します。 これは、受信者に表示される識別子です。
- [ ストレージの場所 ] で、ノートブックを保存するクラウド ストレージの 外部ロケーション を入力します。 定義された外部ロケーションの下にサブパスを指定できます。 外部ロケーションを指定しない場合、ノートブックはメタストア レベルのストレージの場所 (または "メタストアのルートの場所") に格納されます。 メタストアのルートロケーションが定義されていない場合は、ここに外部ロケーションを入力する必要があります。 「 既存のメタストアに管理ストレージを追加する」を参照してください。
-
[ 保存 ]をクリックします。
共有ノートブックファイルが 「アセット 」タブの ノートブックファイル リストに表示されます。
共有からノートブック ファイルを削除する
共有からノートブック ファイルを削除するには:
-
Databricks ワークスペースで、[
カタログ] をクリックします。
-
[カタログ ] ウィンドウの上部にある [
] 歯車アイコンをクリックし、[ Delta Sharing ] を選択します。
または、[ クイック アクセス ] ページで [Delta Sharing > ] ボタンをクリックします。
-
[ 自分が共有] タブで、ノートブックを含む共有を見つけ、共有名をクリックします。
-
[アセット] タブで、共有から削除するノートブック ファイルを見つけます。
-
行の右側にある
ケバブメニューをクリックし、[ ノートブックファイルの削除 ]を選択します。
-
確認ダイアログで、[ 削除 ] をクリックします。
共有内のノートブック ファイルを更新する
既に共有しているノートブックを更新するには、再度追加して、[ 共有者 ] フィールドに新しいエイリアスを割り当てる必要があります。 Databricks では、ノートブックの改訂された状態を示す名前 ( <old-name>-update-1
など) を使用することをお勧めします。 変更の受取人への通知が必要な場合があります。 受信者は、更新を利用するために新しいノートブックを選択して複製する必要があります。
受信者に共有へのアクセス権を付与する
受信者に共有アクセス権を付与するには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの GRANT ON SHARE
SQL コマンドを使用できます。
必要な権限 : 次のいずれかです。
- メタストア管理者。
- 共有オブジェクトと受信者オブジェクト ((
USE SHARE
+SET SHARE PERMISSION
) または共有の所有者) および (USE RECIPIENT
または受信者の所有者) の両方に対する委任されたアクセス許可または所有権。
手順については、「 Delta Sharing データ共有へのアクセスを管理する (プロバイダー向け)」を参照してください。 この記事では、共有への受信者のアクセスを取り消す方法についても説明します。
株式と共有の詳細を表示する
共有の一覧または共有に関する詳細を表示するには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの SQL コマンドを使用できます。
必要な権限 : 返される共有のリストは、ロールと権限によって異なります。 メタストアの管理者と USE SHARE
権限を持つユーザーは、すべての共有を表示します。 それ以外の場合は、自分が共有オブジェクトの所有者である共有のみを表示できます。
詳細は次のとおりです。
- 共有の所有者、作成者、作成タイムスタンプ、アップデーター、更新されたタイムスタンプ、コメント。
- 共有内のデータ資産。
- 共有へのアクセス権を持つ受信者。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
Open the Shares tab to view a list of shares.
-
View share details on the Details tab.
To view a list of shares, run the following command in a notebook or the Databricks SQL query editor. Optionally, replace <pattern>
with a LIKE
predicate.
SHOW SHARES [LIKE <pattern>];
To view details about a specific share, run the following command.
DESCRIBE SHARE <share-name>;
To view details about all tables, views, and volumes in a share, run the following command.
SHOW ALL IN SHARE <share-name>;
To view a list of shares, run the following command using the Databricks CLI.
databricks shares list
To view details about a specific share, run the following command.
databricks shares get <share-name>
共有に対する権限を持っている受信者を表示します
受信者にアクセス権が付与されている共有の一覧を表示するには、カタログ エクスプローラー、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリー エディターの SHOW GRANTS TO RECIPIENT
SQL コマンドを使用できます。
必要なアクセス許可 : メタストア管理者、 USE SHARE
特権、または共有オブジェクトの所有者。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find and select the recipient.
-
Go to the Recipients tab to view the list of recipients who can access the share.
Run the following command in a notebook or the Databricks SQL query editor.
SHOW GRANTS ON SHARE <share-name>;
Run the following command using the Databricks CLI.
databricks shares share-permissions <share-name>
共有を更新する
テーブル、ビュー 、 ボリューム、 ノートブック を共有 に追加する だけでなく、次の操作を行うことができます。
- 共有の名前を変更します。
- 共有からテーブル、ビュー、ボリューム、スキーマを削除します。
- 共有のコメントを追加または更新します。
- テーブルの履歴データへのアクセスを有効または無効にして、受信者がテーブルのタイムトラベルクエリまたはストリーミング読み取りを実行できるようにします。
- パーティション定義を追加、更新、または削除します。
- 共有の所有者を変更します。
これらの共有の更新を行うには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの SQL コマンドを使用できます。 Catalog Explorer を使用して共有の名前を変更することはできません。
必要な権限 :共有所有者を更新するには、メタストア管理者、共有オブジェクトの所有者、または USE SHARE
と SET SHARE PERMISSION
の両方の権限を持つユーザーのいずれかである必要があります。 共有名を更新するには、メタストアの管理者(または CREATE_SHARE
権限を持つユーザー) であり 、共有所有者でなければなりません。 他の共有プロパティを更新するには、所有者である必要があります。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find the share you want to update and click its name.
On the share details page, do the following:
- Click the
edit icon next to the Owner or Comment field to update these values.
- Click the kebab menu
button in an asset row to remove it.
- Click Manage assets > Edit assets to update all other properties:
- To remove an asset, clear the checkbox next to the asset.
- To add, update, or remove partition definitions, click Advanced options.
Run the following commands in a notebook or the Databricks SQL editor.
Rename a share:
ALTER SHARE <share-name> RENAME TO <new-share-name>;
Remove tables from a share:
ALTER SHARE share_name REMOVE TABLE <table-name>;
Remove volumes from a share:
ALTER SHARE share_name REMOVE VOLUME <volume-name>;
Add or update a comment on a share:
COMMENT ON SHARE <share-name> IS '<comment>';
Add or modify partitions for a table in a share:
ALTER SHARE <share-name> ADD TABLE <table-name> PARTITION(<clause>);
Change share owner:
ALTER SHARE <share-name> OWNER TO '<principal>'
-- Principal must be an account-level user email address or group name.
Enable history sharing for a table:
ALTER SHARE <share-name> ADD TABLE <table-name> WITH HISTORY;
For details about ALTER SHARE
parameters, see ALTER SHARE.
Run the following commands using the Databricks CLI.
Rename a share:
databricks shares update <share-name> --name <new-share-name>
Remove tables from a share:
databricks shares update <share-name> \
--json '{
"updates": [
{
"action": "REMOVE",
"data_object": {
"name": "<table-full-name>",
"data_object_type": "TABLE",
"shared_as": "<table-alias>"
}
}
]
}'
Remove volumes from a share (using Databricks CLI 0.210 or above):
databricks shares update <share-name> \
--json '{
"updates": [
{
"action": "REMOVE",
"data_object": {
"name": "<volume-full-name>",
"data_object_type": "VOLUME",
"string_shared_as": "<volume-alias>"
}
}
]
}'
Use the name
property if there is no alias for the volume. Use string_shared_as
if there is an alias.
Add or update a comment on a share:
databricks shares update <share-name> --comment '<comment>'
Change share owner:
databricks shares update <share-name> --owner '<principal>'
Principal must be an account-level user email address or group name.
共有を削除する
共有を削除するには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの DELETE SHARE
SQL コマンドを使用できます。 共有の所有者である必要があります。
共有を削除すると、受信者は共有データにアクセスできなくなります。
必要な権限 : 共有オブジェクトの所有者。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, find the share you want to delete and click its name.
-
Click the
kebab menu and select Delete.
-
On the confirmation dialog, click Delete.
Run the following command in a notebook or the Databricks SQL query editor.
DROP SHARE [IF EXISTS] <share-name>;
Run the following command using the Databricks CLI.
databricks shares delete <share-name>