Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read delta Table versions using Table name

Is there a way I can read the delta table versions using the table name rather than the path. The reason I'm looking for this use case is, analyst team just want to know the full snapshot of the table at 2021-02-07 but he/she knows only the table name and they have no idea on ADLS PATH where the actual data resides.

We can read the versions like below from Databricks docs:

# Time travel read
df = spark.read.format("delta").option("timestampAsOf", "2021-02-07").load("PATH OF THE TABLE")

What I'm looking for:

df = spark.read.format("delta").option("timestampAsOf", "2021-02-07").load("TABLE_NAME")

Any help would be appreciated.

like image 245
chaitra k Avatar asked Jul 06 '26 04:07

chaitra k


1 Answers

Instead of load function, you need to use table function:

df = spark.read.option("timestampAsOf", "2021-02-07").table("TABLE_NAME")

but it will work if it was previously saved using .saveAsTable("TABLE_NAME)

Documentation has examples for both reading & writing tables.

like image 167
Alex Ott Avatar answered Jul 10 '26 02:07

Alex Ott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!