Databricks NoneType AttributeError: ‘NoneType’ object has no attribute ‘write’. AttributeError Traceback (most recent call last) <command> in <cell line: >() 20 21 # Write directly to the datalake. —> 22 df.write.format(“delta”).mode(“append”).option(“mergeSchema”, “true”).saveAsTable(f””) 23 24 #df1 = sqlContext.sql(f”select distinct * from “) AttributeError: ‘NoneType’ object has no attribute ‘write’.
You can’t assign the result from a display() nor show() to a variable
df = df.withColumn("columnName", lit("test")).display()
df.write.format("delta").mode("append").option("mergeSchema", "true").saveAsTable(f"db.tableName")
Databricks NoneType
Remove display() and you are able to write to the database.