簡體   English   中英

如何從 Azure ADLS Gen 1 在 Azure 機器學習工作室中注冊特定版本的增量表?

[英]How can I register a specific version of a Delta Table in Azure Machine Learning Studio from Azure ADLS Gen 1?

我在 ADLS Gen 1 中使用 Databricks 中的以下代碼創建了一個增量表:

df.write.format("delta").mode("overwrite").saveAsTable("db.my_tbl", path ='adl://organisation.azuredatalakestore.net/folder_name/my_data')

有時,我重新運行上面的代碼以生成新版本的my_tbl表。 與 delta 表一樣,會構建歷史記錄,並且必須定期對其進行優化和清理。 現在,我經常在 Azure 機器學習工作室中重新訓練 ML Model 並且想知道是否可以注冊特定版本的增量表?

目前,即使在 vaccuming 之后,從my_data文件夾中讀取 parquet 文件時,我的所有 delta 文件(包括舊版本)都已在 Azure ML Studio 中注冊! 那是因為除了打開spark.databricks.delta.retentionDurationCheck.enabled之外,我不能將 delta 表的保留期降低到 168h 以下。 我不想把它關掉。

我通過 ML Studio 接口將我的數據集注冊為文件數據集(不是表格數據集)。 此注冊如下所示:

在此處輸入圖像描述

現在我只看到創建my_data副本並讀取它的選項。 還有其他方法嗎? 你知道我是否可以在路徑中指定一些東西來指向“正確的”.parquet 文件(屬於特定的增量表版本)?

如果您使用 Databricks 並且在移動文件夾時不介意一些解決方法,這里有一個基於清單文件的解決方案。 此腳本列出了您最新的 delta 表版本的所有文件。 它可用於具有增量數據更新的管道。

spark.conf.set("spark.databricks.delta.symlinkFormatManifest.fileSystemCheck.enabled", False) # this is needed if you are using Azure of Google Cloud

from delta.tables import DeltaTable

delta_path=<'full path in data lake pointing to your table'> # note your Databricks needs WRITE access on the data lake!

newpath=<'folder outside delta table'>

delta_table = DeltaTable.forPath(spark, f"{delta_path}")

#clean up existing folder to be on the safe side 
dbutils.fs.rm(f"{newpath}/_symlink_format_manifest", recurse=True)

manifest = delta_table.generate("symlink_format_manifest")

# The automatically created symlink folder needs to be moved out from the delta path!
# Otherwise spark import will not recognize the format, as delta table is expected under this path.  symlink is not a correct delta table partition!

dbutils.fs.mv(f"{delta_path}/_symlink_format_manifest", f"{newpath}/_symlink_format_manifest", recurse=True)

# create the list of parquet files from the manifest
filelist=spark.read.text(f"{newpath}/_symlink_format_manifest/*").rdd.flatMap(lambda x: x).collect()

filelist

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM