https://delta.io logo
a

Afonso de Paula Feliciano

05/26/2023, 6:30 PM
hey folks, I have some dataframes with inferSchema = True and some columns have a nullType specified automatically. When I try to write using Delta, I get this message:
Delta doesn't accept NullTypes in the schema for streaming writes.
Is there a way to write delta using null type? I did some searches but I didn't find anything until the moment
j

JosephK (exDatabricks)

05/26/2023, 6:34 PM
inferSchema is a read method and not really relevant here. It's usually best to define a schema/use delta/iceberg when you read data. Delta Lake can write null values.
a

Afonso de Paula Feliciano

05/26/2023, 6:37 PM
In my case, I read avro files. So the conversion it's hard. The column is like this:
StructField('column', NullType(), True)
j

JosephK (exDatabricks)

05/26/2023, 6:38 PM
a

Afonso de Paula Feliciano

05/26/2023, 6:43 PM
Based on this, is there a way to convert an avro file with null type to string type for example?
j

JosephK (exDatabricks)

05/26/2023, 6:44 PM
yeah, you'd just cast column to a string before you write it
a

Afonso de Paula Feliciano

05/26/2023, 6:44 PM
hummm, but when I try, the return is:
Cannot convert Avro field 'column' to SQL field column' because schema is incompatible (avroType = "null", sqlType = STRING)
j

JosephK (exDatabricks)

05/26/2023, 6:45 PM
shrug
2 Views