<?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: DLT schema ambiguity in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/dlt-schema-ambiguity/m-p/18775#M12504</link>
    <description>&lt;P&gt;A colleague also having the same issue. He thinks he might be close to a solution. I'll update if he does find one.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jun 2022 12:59:00 GMT</pubDate>
    <dc:creator>PeteC</dc:creator>
    <dc:date>2022-06-30T12:59:00Z</dc:date>
    <item>
      <title>DLT schema ambiguity</title>
      <link>https://community.databricks.com/t5/data-engineering/dlt-schema-ambiguity/m-p/18773#M12502</link>
      <description>&lt;P&gt;I have schema:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;|    |-- costCentres: struct (nullable = true)
 |    |    |-- dimension1: struct (nullable = true)
 |    |    |    |-- name: string (nullable = true)
 |    |    |    |-- value: string (nullable = true)
 |    |    |-- dimension10: struct (nullable = true)
 |    |    |    |-- name: string (nullable = true)
 |    |    |    |-- value: string (nullable = true)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I use dataframe to select and save:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df = df_positions.selectExpr(
    "positions.costCentres.dimension1.value as u_kb01",
    "positions.costCentres.dimension10.value as u_kb10",
    "positions.costCentres.dimension2.value as u_kb02",
    "positions.costCentres.dimension3.value as u_kb03",
    "positions.costCentres.dimension4.value as u_kb04",
    "positions.costCentres.dimension5.value as u_kb05",
    "positions.costCentres.dimension6.value as u_kb06",
    "positions.costCentres.dimension7.value as u_kb07",
    "positions.costCentres.dimension8.value as u_kb08",
    "positions.costCentres.dimension9.value as u_kb09",
).distinct()
&amp;nbsp;
df.write.saveAsTable("test_costcenters")
df.write.save("/temp/test_costcenters")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get required result and I'm happy. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I do the same in Delta Live tables:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def gold_costcenter(): 
    return df_positions.selectExpr(
                            "positions.costCentres.dimension1.value as u_kb01",
                            "positions.costCentres.dimension10.value as u_kb10",
                            "positions.costCentres.dimension2.value as u_kb02",
                            "positions.costCentres.dimension3.value as u_kb03",
                            "positions.costCentres.dimension4.value as u_kb04",
                            "positions.costCentres.dimension5.value as u_kb05",
                            "positions.costCentres.dimension6.value as u_kb06",
                            "positions.costCentres.dimension7.value as u_kb07",
                            "positions.costCentres.dimension8.value as u_kb08",
                            "positions.costCentres.dimension9.value as u_kb09",
                        ).distinct()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get an error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;org.apache.spark.sql.AnalysisException: Ambiguous reference to fields StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true), StructField(value,StringType,true)
at org.apache.spark.sql.errors.QueryCompilationErrors$.ambiguousReferenceToFieldsError(QueryCompilationErrors.scala:1587)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why??? And how to resolve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 08:35:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dlt-schema-ambiguity/m-p/18773#M12502</guid>
      <dc:creator>merca</dc:creator>
      <dc:date>2022-06-03T08:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: DLT schema ambiguity</title>
      <link>https://community.databricks.com/t5/data-engineering/dlt-schema-ambiguity/m-p/18774#M12503</link>
      <description>&lt;P&gt;I've got the same problem - but using a SQL Select statement (with some explodes).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:29:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dlt-schema-ambiguity/m-p/18774#M12503</guid>
      <dc:creator>PeteC</dc:creator>
      <dc:date>2022-06-28T12:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: DLT schema ambiguity</title>
      <link>https://community.databricks.com/t5/data-engineering/dlt-schema-ambiguity/m-p/18775#M12504</link>
      <description>&lt;P&gt;A colleague also having the same issue. He thinks he might be close to a solution. I'll update if he does find one.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 12:59:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dlt-schema-ambiguity/m-p/18775#M12504</guid>
      <dc:creator>PeteC</dc:creator>
      <dc:date>2022-06-30T12:59:00Z</dc:date>
    </item>
  </channel>
</rss>

