-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task: Support Azure Unity Catalog export (#7554)
* Task: Support Azure Unity Catalog export * Fix test * Fix transform func name * Fix test for real * CR Fixes * CR Fixes 2
- Loading branch information
Showing
9 changed files
with
227 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
esti/export_hooks_files/delta/azure_adls/_lakefs_actions/delta_export.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Delta Exporter | ||
on: | ||
post-commit: | ||
branches: ["{{ .Branch }}*"] | ||
hooks: | ||
- id: delta_exporter | ||
type: lua | ||
properties: | ||
script: | | ||
local azure = require("azure") | ||
local formats = require("formats") | ||
local delta_exporter = require("lakefs/catalogexport/delta_exporter") | ||
local json = require("encoding/json") | ||
local table_descriptors_path = "_lakefs_tables" | ||
local sc = azure.blob_client(args.azure.storage_account, args.azure.access_key) | ||
local function write_object(_, key, buf) | ||
return sc.put_object(key,buf) | ||
end | ||
local delta_client = formats.delta_client(args.lakefs.access_key_id, args.lakefs.secret_access_key) | ||
local delta_table_details = delta_exporter.export_delta_log(action, args.table_names, write_object, delta_client, table_descriptors_path, azure.abfss_transform_path) | ||
for t, details in pairs(delta_table_details) do | ||
if details["path"] == nil then | ||
error("Delta Lake exported table \"" .. t .. "\"'s location is not available\n") | ||
end | ||
print("Delta Lake exported table \"" .. t .. "\"'s location: " .. details["path"] .. "\n") | ||
if details["metadata"] == nil then | ||
error("Delta Lake exported table \"" .. t .. "\"'s metadata is not available\n") | ||
end | ||
print("Delta Lake exported table \"" .. t .. "\"'s metadata:\n") | ||
for k, v in pairs(details["metadata"]) do | ||
if type(v) ~= "table" then | ||
print("\t" .. k .. " = " .. v .. "\n") | ||
else | ||
print("\t" .. k .. " = " .. json.marshal(v) .. "\n") | ||
end | ||
end | ||
end | ||
args: | ||
azure: | ||
storage_account: "{{ .AzureStorageAccount }}" | ||
access_key: "{{ .AzureAccessKey }}" | ||
lakefs: # provide credentials of a user that has access to the script and Delta Table | ||
access_key_id: "{{ .LakeFSAccessKeyID }}" | ||
secret_access_key: "{{ .LakeFSSecretAccessKey }}" | ||
table_names: | ||
- test-table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--[[ | ||
As an exhaustive example, it will first start off with a Delta Lake tables export, then continue to register the table | ||
with Unity Catalog | ||
]] | ||
|
||
local azure = require("azure") | ||
local formats = require("formats") | ||
local databricks = require("databricks") | ||
local delta_exporter = require("lakefs/catalogexport/delta_exporter") | ||
local unity_exporter = require("lakefs/catalogexport/unity_exporter") | ||
|
||
local table_descriptors_path = "_lakefs_tables" | ||
local sc = azure.blob_client(args.azure.storage_account, args.azure.access_key) | ||
local function write_object(_, key, buf) | ||
return sc.put_object(key,buf) | ||
end | ||
local delta_client = formats.delta_client(args.lakefs.access_key_id, args.lakefs.secret_access_key) | ||
local delta_table_details = delta_exporter.export_delta_log(action, args.table_defs, write_object, delta_client, table_descriptors_path, azure.abfss_transform_path) | ||
|
||
-- Register the exported table in Unity Catalog: | ||
local databricks_client = databricks.client(args.databricks_host, args.databricks_token) | ||
local registration_statuses = unity_exporter.register_tables(action, "_lakefs_tables", delta_table_details, databricks_client, args.warehouse_id) | ||
for t, status in pairs(registration_statuses) do | ||
print("Unity catalog registration for table \"" .. t .. "\" completed with status: " .. status .. "\n") | ||
end |
Oops, something went wrong.