cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

SELECT from table saved under path

johnb1
New Contributor III

Hi!

I saved a dataframe as a delta table with the following syntax:

(test_df
  .write
  .format("delta")
  .mode("overwrite")
  .save(output_path)
)

How can I issue a SELECT statement on the table?

What do I need to insert into [table_name] below?

SELECT * FROM [table_name]

4 REPLIES 4

Ajay-Pandey
Esteemed Contributor III

Hi @John Bโ€‹ there is two way to access your delta table-

SELECT * FROM delta.`your_delta_table_path`
df.write.format("delta").mode("overwrite").option("path", "your_path").saveAsTable("table_name")

Now you can use your select query-

SELECT * FROM [table_name]

johnb1
New Contributor III

Hi @Ajay Pandeyโ€‹ 

When trying the first option I get:

image.pngimage

Ajay-Pandey
Esteemed Contributor III

Hi @John Bโ€‹ in the above code instead of your path variable put your absolute path. Please refer to snapshot-

image.png

Ajay-Pandey
Esteemed Contributor III

image.pngimage.png

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.