<?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: How to create Delta Live table from Json files using Custom schema? I am getting the below error for the attached code

# Error

org.apache.spark.sql.AnalysisException: Table  has a user-specified schema that is incompatible with the schema in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8034#M3762</link>
    <description>&lt;P&gt;Thanks Suteja, but the issue has been resolved. We can actually use custom schema in delta live.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 12:51:49 GMT</pubDate>
    <dc:creator>Abhradwip</dc:creator>
    <dc:date>2023-03-24T12:51:49Z</dc:date>
    <item>
      <title>How to create Delta Live table from Json files using Custom schema? I am getting the below error for the attached code

# Error

org.apache.spark.sql.AnalysisException: Table  has a user-specified schema that is incompatible with the schema</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8032#M3760</link>
      <description>&lt;P&gt;#### Code&lt;/P&gt;&lt;P&gt;# CodeImport DataType&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;from pyspark.sql.types import StructType, StructField, TimestampType, IntegerType, StringType, FloatType, BooleanType, LongType&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Define Custom Schema&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;call_schema = StructType(&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;[&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("RecordType", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("SystemIdentity", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("FileNum", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("SwitchNum", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CallingNum", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CallingIMSI", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CalledNum", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CalledIMSI", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("DateS", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("TimeS", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("TimeType", LongType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CallPeriod", LongType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CallingCellID", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CalledCellID", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("ServiceType", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("Transfer", LongType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("IncomingTrunk", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("OutgoingTrunk", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("MSRN", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("CalledNum2", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("FCIFlag", StringType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("callrecTime", TimestampType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("EventProcessedUtcTime", TimestampType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("PartitionId", LongType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StructField("EventEnqueuedUtcTime", TimestampType(), True),&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;]&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;)&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Define Delta Live Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;import dlt&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;from pyspark.sql.functions import *&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;from pyspark.sql.types import *&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;json_path = "/mnt/adlspoc23/stream/"&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;@dlt.table(&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;comment="The raw Telecom callstream dataset, ingested from ADLS.",&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;schema=call_schema&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;)&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;def callstream_raw():&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;&amp;nbsp;return (spark.read.format("json").load(json_path))&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Error&lt;/P&gt;&lt;P&gt;org.apache.spark.sql.AnalysisException: Table 'callstream_raw' has a user-specified schema that is incompatible with the schema inferred from its query.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 10:29:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8032#M3760</guid>
      <dc:creator>Abhradwip</dc:creator>
      <dc:date>2023-03-09T10:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Delta Live table from Json files using Custom schema? I am getting the below error for the attached code

# Error

org.apache.spark.sql.AnalysisException: Table  has a user-specified schema that is incompatible with the schema</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8033#M3761</link>
      <description>&lt;P&gt;@Abhradwip Mukherjee​&amp;nbsp;; The &lt;B&gt;error&lt;/B&gt; you're seeing occurs because the schema you're specifying for your Delta Live table is not compatible with the schema of the data being read from the JSON files.&lt;/P&gt;&lt;P&gt;You should check that the schema you have specified matches the schema of the data you are trying to load. You can also try loading the data without specifying a schema, allowing Spark to infer the schema automatically&lt;/P&gt;&lt;P&gt;You can try to update the code to include an explicit schema definition when reading the JSON files so that it matches the schema you've specified for the Delta Live table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you to debug!&lt;/P&gt;&lt;P&gt;Asides, the code you presented seems okay.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 07:46:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8033#M3761</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-16T07:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Delta Live table from Json files using Custom schema? I am getting the below error for the attached code

# Error

org.apache.spark.sql.AnalysisException: Table  has a user-specified schema that is incompatible with the schema</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8034#M3762</link>
      <description>&lt;P&gt;Thanks Suteja, but the issue has been resolved. We can actually use custom schema in delta live.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 12:51:49 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8034#M3762</guid>
      <dc:creator>Abhradwip</dc:creator>
      <dc:date>2023-03-24T12:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Delta Live table from Json files using Custom schema? I am getting the below error for the attached code

# Error

org.apache.spark.sql.AnalysisException: Table  has a user-specified schema that is incompatible with the schema</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8035#M3763</link>
      <description>&lt;P&gt;Hi @Abhradwip Mukherjee​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2023 00:22:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-create-delta-live-table-from-json-files-using-custom/m-p/8035#M3763</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-01T00:22:23Z</dc:date>
    </item>
  </channel>
</rss>

