As it requires some manipulation, it will be easier to handle it as dataframe in Python as there you can just use:

df.schema.fieldNames.contains("col2.C")

and apply logic accoridngly


My blog: https://databrickster.medium.com/