概要
Databricks 上でストレージキーにて Azure Storage 上の Apache Iceberg のデータを CLONE しようとした際の暫定対応方法を共有します。Blob Storage エンドポイントを指定しているにもかかわらず、内部で dfs エンドポイントにより接続していることがエラーの原因のようです。dfs に対する認証情報も追加する暫定対応を共有します。
Py4JJavaError: An error occurred while calling o400.sql.
: Invalid configuration value detected for fs.azure.account.key
at shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.dia
Py4JJavaError: An error occurred while calling o400.sql.
: shaded.databricks.org.apache.hadoop.fs.azure.AzureException: shaded.databricks.org.apache.hadoop.fs.azure.AzureException: Unable to access container snowflake in account snowflakeicebergqiita.blob.core.windows.net using anonymous credentials, and no credentials found for them in the configuration.
Unity Catalog に外部ロケーションとして登録しているディレクトリの場合においても、上記の 2 つのエンドポイントに対する認証設定が必要でした。
Py4JJavaError: An error occurred while calling o400.sql.
: shaded.databricks.org.apache.hadoop.fs.azure.AzureException: shaded.databricks.org.apache.hadoop.fs.azure.AzureException: Unable to access container external in account {account_name}.blob.core.windows.net using anonymous credentials, and no credentials found for them in the configuration.
エラーについて
Unity Catalog が有効なクラスターのアタッチ
cluster_info = spark.conf.get("spark.databricks.clusterUsageTags.sparkVersion")
display(cluster_info)
Blob Storage エンドポイントの認証を設定
# Azure Storage に関る情報をセット
azure_storage_account_name = "snowflakeicebergqiita"
azure_storage_account_key = "kKRn6nruDHEhUF0AQzM1PFlXtXs9V0BJQSrn6Z8GvJOsb0JHflV9Fn=="
spark.conf.set(f"fs.azure.account.key.{azure_storage_account_name}.blob.core.windows.net", azure_storage_account_key)
CLONE がエラーとなることを確認
retund_df = spark.sql(f"""
CREATE OR REPLACE TABLE iceberg_clone_test.default.test_table_01
CLONE iceberg.`wasbs://snowflake@{azure_storage_account_name}.blob.core.windows.net/iceberg_clone/default/first_table`;
""")
retund_df.display()
Py4JJavaError: An error occurred while calling o400.sql.
: Invalid configuration value detected for fs.azure.account.key
at shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.dia
エラーへの対応方法
dfs エンドポイントに対する認証を設定
spark.conf.set(
f"fs.azure.account.key.{azure_storage_account_name}.dfs.core.windows.net",
azure_storage_account_key,
)
CLONE できることを確認
retund_df = spark.sql(f"""
CREATE OR REPLACE TABLE iceberg_clone_test.default.test_table_01
CLONE iceberg.`wasbs://snowflake@{azure_storage_account_name}.blob.core.windows.net/iceberg_clone/default/first_table`;
""")
retund_df.display()