cancel
Showing results for 
Search instead for 
Did you mean: 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results for 
Search instead for 
Did you mean: 

write to Delta

SSV_dataeng
New Contributor II
spark.conf.set("spark.databricks.delta.properties.defaults.columnMapping.mode","name")
products_output_path = DA.paths.working_dir + "/delta/products"
products_df.write.format("delta").save(products_output_path)
 
verify_files = dbutils.fs.ls(products_output_path)
verify_delta_format = False
verify_num_data_files = 0
for f in verify_files:
    if f.name == "_delta_log/":
        verify_delta_format = True
    elif f.name.endswith(".parquet"😞
        verify_num_data_files += 1

assert verify_delta_format, "Data not written in Delta format"
assert verify_num_data_files > 0, "No data written"
del verify_files, verify_delta_format, verify_num_data_files
print("All test pass")
 
AssertionError Traceback (most recent call last) <command-1787238488083573> in <cell line: 11>() 9 10 assert verify_delta_format, "Data not written in Delta format" ---> 11 assert verify_num_data_files > 0, "No data written" 12 del verify_files, verify_delta_format, verify_num_data_files 13 print("All test pass") AssertionError: No data written
4 REPLIES 4

daniel_sahal
Esteemed Contributor

@SSV_dataeng 
What is the question here?

1. I was trying to create a file in Delta format. After Delta File creation at the verification step getting Assertion Error: No data written.

could you please let me know how to fix this issue?

 

Lakshay
Esteemed Contributor

I see the error is part of the assertion part of your code. Do you see any other error when writing the data?

NandiniN
Honored Contributor

Hi @SSV_dataeng ,

Please check with this (you would have to indent it correctly for python)

productsOutputPath = DA.workingDir + "/delta/products"
(productsDF
.write
.format("delta")
.mode("overwrite")
.save(productsOutputPath)
)

verify_files = dbutils.fs.ls(productsOutputPath)
verify_delta_format = False
verify_num_data_files = 0
for f in verify_files:
if f.name == '_delta_log/':
verify_delta_format = True
elif f.name.endswith('.parquet'):
verify_num_data_files += 1

assert verify_delta_format, "Data not written in Delta format"
assert verify_num_data_files > 0, "No data written"
del verify_files, verify_delta_format, verify_num_data_files

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group