d_meaker
New Contributor II

Hi @Suteja Kanuri​ ,

Thank you for you response and explanation. The code I have shown above is not the exact snippet we are using. Please find the exact snippet below. We are dynamically extracting the keys of the map and then using getitem() to make columns from the fields, with the key names the names of the columns:

    df = df.withColumn(column_name, from_json(column_name, MapType(StringType(),StringType())))
 
    keys = (
        df
        .select(map_keys(column_name))
        .distinct()
        .collect()
        )
    
    
    df = df.select(
        [col(column_name).getItem(k).alias(k) for k in keys] + [filter_column]
    )

I have checked the data, and its identical. Do you know if the dynamic way is supported in Delta Live Tables?