<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Compiling Flattened Dataframe back to Struct Columns in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/compiling-flattened-dataframe-back-to-struct-columns/m-p/3668#M640</link>
    <description>&lt;P&gt;I have figured out the solution.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2023 04:43:01 GMT</pubDate>
    <dc:creator>etsyal1e2r3</dc:creator>
    <dc:date>2023-06-06T04:43:01Z</dc:date>
    <item>
      <title>Compiling Flattened Dataframe back to Struct Columns</title>
      <link>https://community.databricks.com/t5/data-engineering/compiling-flattened-dataframe-back-to-struct-columns/m-p/3667#M639</link>
      <description>&lt;P&gt;I have a dataframe with this format of columns:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[`first.second.third` , `alpha.bravo.test1` , `alpha.bravo.test2`]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'd like to get an output dataframe of this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[               `first`                  |              `alpha`             ]
-------------------------------------------
[{'second':                        |    [{'bravo':
        [{'third': value}]        |         [{'test1': value}     
                                          |         {'test2': value} ]
 }]                                      |    }]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried doing something like this but have some errors with using *select_list&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AnalysisException: [UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `F`.`col("_timestamp"),` cannot be resolved.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But manually putting in generated list of select cols with structs works but not exactly what I want.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/121i5F3380863D4A408E/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;In the above example the columns were...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[`cloud-provider` , `cloud-region` , `cloud-service-name`]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So the desired result is supposed to be...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[`cloud`]
-------
[{'provider': value},
{'region': value},
{'service': {
        'name': value}}]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you for your help!!!&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2023 00:00:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/compiling-flattened-dataframe-back-to-struct-columns/m-p/3667#M639</guid>
      <dc:creator>etsyal1e2r3</dc:creator>
      <dc:date>2023-06-04T00:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Compiling Flattened Dataframe back to Struct Columns</title>
      <link>https://community.databricks.com/t5/data-engineering/compiling-flattened-dataframe-back-to-struct-columns/m-p/3668#M640</link>
      <description>&lt;P&gt;I have figured out the solution.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 04:43:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/compiling-flattened-dataframe-back-to-struct-columns/m-p/3668#M640</guid>
      <dc:creator>etsyal1e2r3</dc:creator>
      <dc:date>2023-06-06T04:43:01Z</dc:date>
    </item>
  </channel>
</rss>

