type_changes issue

Rohit Kulkarni 686 Reputation points

Hello Team,

I have written the code to get the latest version of the change data field.

max_version = spark.sql("DESCRIBE HISTORY <tableName>").collect()[0][0]

delta_df = spark.sql(f"SELECT * FROM table_changes('<tableName>',{max_version}) order by _commit_timestamp")


I need to get only 1st row from the below mentioned screenshot:

User's image

It is executing perfectly.But with "Query Result No Data"

Please advise



Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
1,955 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 31,561 Reputation points Microsoft Employee

    Hi @Rohit Kulkarni ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your query here.

    As per my understanding, you are trying to fetch only the first row out of the the data

    If your code is executing without errors but returning "Query Result No Data", it is likely that the query is not returning any rows of data.

    In this case, you can modify your code to select only the first row from the DataFrame using the limit() function instead of display(delta_df), use display(delta_df.limit(1))

    This will return only the first row of data from the delta_df DataFrame. If there are no rows of data, it will return an empty DataFrame.

    Hope it helps. Kindly accept the answer if it helps. Thanks

    0 comments No comments