我已在 Azure 数据工厂中发布了一个数据集,但无法访问 databricks 中的数据集。
我尝试阅读 Azure 上的文档,但大多数文档都会建议将此数据放入 Azure Data Lake Storage 中。这是访问数据块中数据的唯一方法吗?
请提供任何好的文档链接。
通过设置必要的凭据和配置,将 Azure Databricks 配置为直接从 AWS S3 访问数据。
了解有关外部位置和存储凭证的更多信息,并创建 IAM 角色
使用 Unity Catalog 卷或外部位置访问 S3 存储桶
以下代码将帮助您读取和写入S3存储桶:
从S3读取文件:
dbutils.fs.ls("s3://my-bucket/external-location/path/to/data")
spark.read.format("parquet").load("s3://my-bucket/external-location/path/to/data")
spark.sql("SELECT * FROM parquet.`s3://my-bucket/external-location/path/to/data`")
写入文件:
dbutils.fs.mv("s3://my-bucket/external-location/path/to/data", "s3://my-bucket/external-location/path/to/new-location")
df.write.format("parquet").save("s3://my-bucket/external-location/path/to/new-location")