Datalake - Get Last file modified date in Synapse notebook

Sivagnana Sundaram, Krithiga 31 Reputation points

Hi - I am trying to get the last modified date of the file in datalake (ADLS Gen2) using Spark notebook. I am using the mssparkutils, but don't see an option to actually get the file specifics.

Is there any options that I can try?

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,378 questions
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,497 questions
{count} votes

Accepted answer
  1. Saurabh Sharma 23,766 Reputation points Microsoft Employee

    Currently mssparkutils doesn’t expose file modified time info to customer when calling API.
    As a workaround you can directly call Hadoop filesystem APIs to get the time info.

    import org.apache.hadoop.fs.FileSystem;  
    import org.apache.hadoop.fs.Path;  
    import org.apache.hadoop.fs.FileStatus;  
    val conf = spark.sessionState.newHadoopConf()  
    val fs = FileSystem.get(new URI("/"), conf)  
    for (fileStatus <- fs.listStatus(new Path("/"))) {  
        println(s"file name: ${fileStatus.getPath.getName} - modify time: ${fileStatus.getModificationTime}")  


    Additionally, products team has open an internal workitem to address the same in future releases. Please let me know if you have any questions.



    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful