Delta Lakeテーブルのプロパティを設定する
適用対象 : SaaS コネクタ
データベース コネクタ
クエリーベースのコネクタ
管理された取り込みパイプラインによって作成される宛先ストリーミングテーブルに対して、Delta Lake テーブルプロパティを設定できます。宛先テーブルはパイプラインによって管理されるストリーミングテーブルであるため、ALTER TABLE ... SET TBLPROPERTIES を直接実行するのではなく、パイプラインの ingestion_definition を通じてテーブルプロパティを設定します。パイプライン仕様で table_properties を指定することは、ALTER TABLE ... SET TBLPROPERTIES コマンドと同じ効果があります。
テーブルプロパティは、次の2つのレベルで設定できます。
レベル | 挙動 |
|---|---|
パイプライン | パイプラインレベルの |
テーブルまたはスキーマ | 個々のテーブルまたはスキーマの |
テーブルプロパティを有効にする前に、その機能のリーダーおよびライターバージョンの要件を確認してください。プロパティ固有の要件については、「テーブルプロパティのリファレンス」および「型拡張」など、有効にする機能のドキュメントを参照してください。
API を使用したテーブルプロパティの設定
Declarative Automation Bundles、ノートブック、または Databricks CLI を使用してマネージド インジェスト パイプラインを作成または編集する際に、テーブル プロパティを設定できます。
次の例では、パイプラインレベルで型の拡張を有効にし、users_1 宛先テーブルに対してそれを false に上書きします。calendar_test テーブルは、パイプラインレベルの設定を継承します。
- Declarative Automation Bundles
- Databricks notebook
- Databricks CLI
resources:
pipelines:
pipeline_cdc:
name: <pipeline-name>
catalog: <destination-catalog>
schema: <destination-schema>
ingestion_definition:
ingestion_gateway_id: <gateway-pipeline-id>
table_configuration:
table_properties:
delta.enableTypeWidening: 'true'
delta.enableDeletionVectors: 'true'
objects:
- table:
source_schema: <source-schema>
source_table: users_1
destination_catalog: <destination-catalog>
destination_schema: <destination-schema>
table_configuration:
table_properties:
delta.enableTypeWidening: 'false'
- table:
source_schema: <source-schema>
source_table: calendar_test
destination_catalog: <destination-catalog>
destination_schema: <destination-schema>
pipeline_spec = """
{
"ingestion_definition": {
"ingestion_gateway_id": "<gateway-pipeline-id>",
"table_configuration": {
"table_properties": {
"delta.enableTypeWidening": "true",
"delta.enableDeletionVectors": "true"
}
},
"objects": [
{
"table": {
"source_schema": "<source-schema>",
"source_table": "users_1",
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>",
"table_configuration": {
"table_properties": {
"delta.enableTypeWidening": "false"
}
}
}
},
{
"table": {
"source_schema": "<source-schema>",
"source_table": "calendar_test",
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>"
}
}
]
}
}
"""
{
"ingestion_definition": {
"ingestion_gateway_id": "<gateway-pipeline-id>",
"table_configuration": {
"table_properties": {
"delta.enableTypeWidening": "true",
"delta.enableDeletionVectors": "true"
}
},
"objects": [
{
"table": {
"source_schema": "<source-schema>",
"source_table": "users_1",
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>",
"table_configuration": {
"table_properties": {
"delta.enableTypeWidening": "false"
}
}
}
},
{
"table": {
"source_schema": "<source-schema>",
"source_table": "calendar_test",
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>"
}
}
]
}
}
単一の table_properties ブロック内で複数のテーブルプロパティを指定できます。
列名で特殊文字をサポートする
Delta Lakeでdefaultでは許可されていない文字(スペース、カンマ、かっこなど)がソース列名に含まれていると、パイプラインはDELTA_INVALID_CHARACTERS_IN_COLUMN_NAMESエラーで失敗します。これは、SharePointのExcelファイルやCSVファイルなど、ビジネスユーザーがヘッダーを管理しているファイルを取り込む場合によく発生します。文字の全リストについては、列名でサポートされている文字を参照してください。
これらの列の名前を変更せずに取り込むには、そのテーブルのtable_configurationのtable_propertiesでdelta.columnMapping.modeをnameに設定して、宛先テーブルのDelta Lake列マッピングを有効にします。影響を受ける各テーブルのパイプライン仕様にプロパティを追加します。
次の例では、SharePointファイル取り込みパイプラインの宛先テーブルで列マッピングを有効にします:
- Declarative Automation Bundles
- Databricks notebook
resources:
pipelines:
sharepoint_csv_pipeline:
name: sharepoint_csv_pipeline
catalog: <destination-catalog>
schema: <destination-schema>
channel: PREVIEW
ingestion_definition:
connection_name: <sharepoint-connection>
objects:
- table:
destination_catalog: <destination-catalog>
destination_schema: <destination-schema>
destination_table: <destination-table>
table_configuration:
table_properties:
delta.columnMapping.mode: 'name'
connector_options:
sharepoint_options:
entity_type: FILE
url: https://<tenant>.sharepoint.com/sites/<site>/<folder>
file_ingestion_options:
format: CSV
schema_evolution_mode: NONE
pipeline_spec = """
{
"name": "<pipeline-name>",
"catalog": "<destination-catalog>",
"schema": "<destination-schema>",
"channel": "PREVIEW",
"ingestion_definition": {
"connection_name": "<sharepoint-connection>",
"objects": [
{
"table": {
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>",
"destination_table": "<destination-table>",
"table_configuration": {
"table_properties": {
"delta.columnMapping.mode": "name"
}
},
"connector_options": {
"sharepoint_options": {
"entity_type": "FILE",
"url": "https://<tenant>.sharepoint.com/sites/<site>/<folder>",
"file_ingestion_options": {
"format": "CSV",
"schema_evolution_mode": "NONE"
}
}
}
}
}
]
}
}
"""
マネージド取り込みパイプラインで列マッピングを有効にする際は、次の点に注意してください:
- テーブルの
table_propertiesでプロパティを設定します。パイプライン構成でspark.databricks.delta.properties.defaults.columnMapping.modeを設定しても、列マッピングを有効にして宛先テーブルを事前に作成しても、エラーは解消されません。パイプラインが宛先のストリーミングテーブルを所有しているため、そのテーブルでALTER TABLE ... SET TBLPROPERTIESをランすることもできません。 table_propertiesを仕様に追加すると、パイプラインに警告が表示されることがあります。パイプラインは引き続きランされます。
列マッピングによってテーブルプロトコルがリーダーバージョン2、ライターバージョン5にアップグレードされるため、従来のパーティションディレクトリを使用するワークロード、チェンジデータフィード、およびテーブルからのストリーミング読み取りに影響する可能性があります。詳細については、制限事項を参照してください。
継承と上書き
テーブルプロパティは継承モデルに従っており、個々のテーブルまたはスキーマに適用された設定が、パイプラインレベルのdefault設定よりも優先されます。
- パイプラインレベルで設定されたテーブルプロパティは、パイプライン内のすべてのテーブルとスキーマに継承されます。
- テーブルまたはスキーマレベルで設定された
table_configurationは、パイプラインレベルの構成を上書きします。テーブルまたはスキーマレベルで上書きを行うと、他のパイプラインレベルのテーブル構成は継承されません。パイプラインレベルの構成を保持するには、オーバーライドでそれを繰り返します。
制限事項
マネージド取り込みパイプラインでテーブルプロパティを設定する場合、次の制限が適用されます。
パイプライン仕様からテーブル・プロパティを削除しても、基盤となるテーブル機能は自動的には元に戻りません。例えば、delta.enableTypeWidening を有効にした後に、リーダーの Databricks Runtime バージョンが型の拡張をサポートしていないことが判明した場合、仕様からプロパティを削除しても変更は取り消されません。その場合は、影響を受けるテーブルの完全更新を実行する必要があります。テーブル・プロパティを変更する前に、プロパティを元に戻すことで問題が解決するか、それとも完全更新が必要かを確認してください。ターゲットテーブルの完全更新を参照してください。