I have a DeltaTable with several columns that are ArrayTypes, containing StructTypes.
I'm trying to add an extra column into the StructType, but I am running into issues because it is wrapped in an ArrayType.
Hoping someone has a way to do this, or similar method that doesn't involve me backing up the table, creating the table again from scratch and restoring the data from the back-up.
I am currently using this command:
spark.sql(f"ALTER TABLE {db}.ads ADD COLUMNS (response.monkey boolean AFTER dq_conveyed)")
Which would work if it was only a StructType, but is failing because it's an array
This is the current Schema I'm trying to make the change to:
StructField(response,ArrayType(StructType(
StructField(encounter_uid,StringType,true),
StructField(patient_uid,StringType,true),
StructField(call_sign,StringType,true),
StructField(time_resource_allocated,StringType,true),
StructField(time_resource_arrived_at_receiving_location,StringType,true),
StructField(time_of_patient_handover,StringType,true),
StructField(time_clear,StringType,true),
StructField(response_type,StringType,true),
StructField(time_resource_mobilised,StringType,true),
StructField(time_resource_arrived_on_scene,StringType,true),
StructField(time_stood_down,StringType,true),
StructField(time_resource_left_scene,StringType,true),
StructField(highest_skill_level_on_vehicle,StringType,true),
StructField(responding_organisation_type,StringType,true),
StructField(dq_conveyed,BooleanType,true)),
true),true)
I'm following this documentation: