Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
567 views
in Technique[技术] by (71.8m points)

apache spark - Azure Databricks : Mount delta table used in another workspace

Currently I have an azure databricks instance where I have the following

myDF.withColumn("created_on", current_timestamp())
.writeStream
.format("delta")
.trigger(processingTime= triggerDuration)
.outputMode("append")
.option("checkpointLocation", "/mnt/datalake/_checkpoint_Position")
.option("path", "/mnt/datalake/DeltaData")
.partitionBy("col1", "col2", "col3", "col4", "col5")
.table("deltadata")

This is saving the data into a storage account as blobs.

Now, I'm trying to connect to this table from another azure databricks workspace and my first "move" is the mount to the azure storage account:

dbutils.fs.mount(
    source = sourceString,
    mountPoint = "/mnt/data",
    extraConfigs = Map(confKey -> sasKey)

Note: sourceString, confKey and sasKey are not shown for obvious reasons, in any case the mount works fine.

And then I try to create the table, but I get an error:

CREATE TABLE delta_data USING DELTA LOCATION '/mnt/data/DeltaData/'

Error in SQL statement: AnalysisException: 
You are trying to create an external table `default`.`delta_data`
from `/mnt/data/DeltaData` using Databricks Delta, but the schema is not specified when the
input path is empty.

According to the documentation the schema should be picked up from the existing data correct? Also, I trying to do this in a different workspace because the idea is to give only read access to people.

question from:https://stackoverflow.com/questions/65905016/azure-databricks-mount-delta-table-used-in-another-workspace

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems my issue was the mount. It did not give any error while creating it but was not working fine. I discovered this after trying:

dbutils.fs.ls("/mnt/data/DeltaData")

Which was not showing anything. I unmounted and reviewed all the configs and after that it worked.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...