简体   繁体   English

来自 Databricks 的文件元数据,例如 timein Azure 存储

[英]File metadata such as timein Azure Storage from Databricks

I m trying to get creationfile metadata.我正在尝试获取 creationfile 元数据。

File is in: Azure Storage文件在: Azure 存储
Accesing data throw: Databricks访问数据抛出: Databricks

right now I m using:现在我正在使用:

   file_path = my_storage_path
   dbutils.fs.ls(file_path)

but it returns但它返回
[FileInfo(path='path_myFile.csv', name='fileName.csv', size=437940)] [FileInfo(path='path_myFile.csv', name='fileName.csv', size=437940)]

I do not have any information about creation time, there is a way to get that information?我没有任何关于创建时间的信息,有没有办法获得这些信息?

other solutions in Stackoverflow are refering to files that are already in databricks Does databricks dbfs support file metadata such as file/folder create date or modified date in my case we access to the data from Databricks but the data are in Azure Storage. Stackoverflow 中的其他解决方案是指已经在 databricks 中的文件 databricks dbfs 是否支持文件元数据,例如文件/文件夹创建日期或修改日期在我的情况下,我们从 Databricks 访问数据,但数据位于 Azure 存储中。

It really depends on the version of Databricks Runtime (DBR) that you're using.这实际上取决于您使用的 Databricks Runtime (DBR) 的版本。 For example, modification timestamp is available if you use DBR 10.2 (didn't test with 10.0/10.1, but definitely not available on 9.1):例如,如果您使用 DBR 10.2,则可以使用修改时间戳(未使用 10.0/10.1 进行测试,但在 9.1 上绝对不可用):

在此处输入图像描述

If you need to get that information you can use Hadoop FileSystem API via Py4j gateway, like this:如果您需要获取该信息,您可以通过 Py4j 网关使用Hadoop FileSystem API ,如下所示:

URI           = sc._gateway.jvm.java.net.URI
Path          = sc._gateway.jvm.org.apache.hadoop.fs.Path
FileSystem    = sc._gateway.jvm.org.apache.hadoop.fs.FileSystem
Configuration = sc._gateway.jvm.org.apache.hadoop.conf.Configuration

fs = FileSystem.get(URI("/tmp"), Configuration())

status = fs.listStatus(Path('/tmp/'))
for fileStatus in status:
    print(f"path={fileStatus.getPath()}, size={fileStatus.getLen()}, mod_time={fileStatus.getModificationTime()}")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM