type_changes issue

Rohit Kulkarni 676 Reputation points
2023-03-14T06:48:03.5266667+00:00

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")

display(delta_df)

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

Regards

Rohit

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

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 30,601 Reputation points Microsoft Employee
    2023-03-17T11:40:15.2666667+00:00

    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