Can we assigee default value in select columns in Spark sql when the column is not present?

Manojkumar
New Contributor II

Im reading avro file and loading into table. The avro data is nested data.

Now from this table im trying to extract the necessary elements using spark sql. Using explode function when there is array data. Now the challenge is there are cases like the element that needs to be extracted might not present in avro data in that case default null value should be returned in select statement instead of throwing error.