cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid Characters in Column Names " ,;{}()\n\t="

maxutil
New Contributor II

I'm reading data into a dataframe with

df = spark.read.json("s3://somepath/")

I've tried first creating a delta table using the DeltaTable API with:

DeltaTable.createIfNotExists(spark)\
            .location(target_path)\
            .addColumns(df.schema)\
            .execute()

This is giving me an AnalysisException and says I have invalid characters. I should set the table property 'delta.columnMapping.mode' to 'name'. I've tried:

spark.conf.set("spark.databricks.delta.defaults.columnMapping.mode", "name")

This hasn't worked. I've tried to use the DataFrame API instead:

df.write.format("delta").option("delta.columnMapping.mode", "name").save("s3://anotherpath")

But the same error message is coming up. The erroneous column names are deeply nested in structs.

Is there some other way for me to accomplish this delta table write (without flattening and fixing col names)?

EDIT: I ended up traversing through the schema and changing the problematic column names.

0 REPLIES 0

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