https://delta.io logo
i

Ian

03/28/2023, 11:31 AM
Hi team, anyone have any idea as to why does spark always set the nullable field as true even when i have mentioned it to be false in the schema? I am trying to create a delta table with empty dataframe and a schema
1
m

Matthew Powers

03/28/2023, 2:48 PM
Can you please post your code snippet?
j

Jim Hibbard

03/28/2023, 3:52 PM
Hi Ian, Spark will convert the schema automatically to be
nullable=true
when writing a Delta Table. It definitely is a little surprising but appears to be the intended behavior. You can read more in this thread: https://github.com/delta-io/delta/issues/873#issuecomment-1006790092
And here is a user's workaround if you want to keep the columns as
nullable=false
: https://github.com/delta-io/delta/issues/873#issuecomment-1014797293 Hope that helps!
i

Ian

03/28/2023, 4:13 PM
Thanks Jim. I was surprised myself as well but continuing to read the thread it made sense. I will try the user workaround. thanks again.
👍 2
j

Jim Hibbard

03/28/2023, 4:14 PM
No problem! I think a lot of users will find your question useful 😄
👍 1
i

Ian

03/28/2023, 4:38 PM
Sure.
3 Views