<?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: DELTA_EXCEED_CHAR_VARCHAR_LIMIT in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/70290#M34048</link>
    <description>&lt;P&gt;Setting this config change before making the write command solved it for us:&amp;nbsp;&amp;nbsp;spark.conf.set("spark.sql.legacy.charVarcharAsString", True)&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2024 17:29:20 GMT</pubDate>
    <dc:creator>willflwrs</dc:creator>
    <dc:date>2024-05-22T17:29:20Z</dc:date>
    <item>
      <title>DELTA_EXCEED_CHAR_VARCHAR_LIMIT</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/61283#M31751</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having an issue of loading source data into a delta table/ unity catalog. The error we are recieving is the following:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;grpc_message:"[DELTA_EXCEED_CHAR_VARCHAR_LIMIT] Exceeds char/varchar type length limitation. Failed check: (isnull(\'metric_name) OR (length(\'metric_name) &amp;lt;= 0))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We get this issue when executing the line below:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;source_df.write.&lt;/SPAN&gt;&lt;SPAN&gt;format&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"delta"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;mode&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"overwrite"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"mergeSchema"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"true"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;save&lt;/SPAN&gt;&lt;SPAN&gt;(destination_mount_filepath)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The background of this is we are loading raw data into a delta table in mounted storage.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I have tried unmounting/remounting storage and recreating the container in storage account. I have checked and validated the data and there are no rows that would fall to this match. I have tried dropping the Unity Catalog tables and using the dbutils to remove the old data behind the Catalog tables to no avail.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 Feb 2024 17:29:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/61283#M31751</guid>
      <dc:creator>Paul92S</dc:creator>
      <dc:date>2024-02-20T17:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: DELTA_EXCEED_CHAR_VARCHAR_LIMIT</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/61302#M31757</link>
      <description>&lt;P&gt;&amp;nbsp;Hey&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/100325"&gt;@Paul92S&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the error message it looks like column &lt;STRONG&gt;"&lt;SPAN&gt;metric_name&lt;/SPAN&gt;"&amp;nbsp;&lt;/STRONG&gt;is the culprit here:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Understanding the Error:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Character Limit Violation:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;The error indicates that values in the&amp;nbsp;&lt;/SPAN&gt;metric_name&lt;SPAN&gt;&amp;nbsp;column are exceeding the maximum length allowed for char/varchar data types in Unity Catalog.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Schema Mismatch:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;This likely stems from a discrepancy between the source data schema and the existing Delta table schema.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Troubleshooting Steps:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Use&amp;nbsp;&lt;/SPAN&gt;source_df.printSchema()&lt;SPAN&gt;&amp;nbsp;to verify the actual schema of your source data,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;paying close attention to the&amp;nbsp;&lt;/SPAN&gt;metric_name&lt;SPAN&gt;&amp;nbsp;column's data type and length.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Use&amp;nbsp;&lt;/SPAN&gt;spark.read.format("delta").load(destination_mount_filepath).printSchema()&lt;SPAN&gt;&amp;nbsp;to inspect the current schema of the Delta table.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;If feasible,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;consider altering the&amp;nbsp;&lt;/SPAN&gt;metric_name&lt;SPAN&gt;&amp;nbsp;column in the Delta table to accommodate longer values using&amp;nbsp;&lt;/SPAN&gt;ALTER TABLE &lt;STRONG&gt;TABLE_NAME&lt;/STRONG&gt; ALTER COLUMN &lt;STRONG&gt;COLUMN_NAME;&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;If increasing column size isn't viable,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;explore truncating values in the&amp;nbsp;&lt;/SPAN&gt;metric_name&lt;SPAN&gt;&amp;nbsp;column before writing to the Delta table.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;If the error message refers to&amp;nbsp;isnull('metric_name'),&amp;nbsp;ensure there are no unintended null values in that column.&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;If empty strings are valid for&amp;nbsp;&lt;/SPAN&gt;metric_name&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;explicitly set those values to empty strings in the source DataFrame.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Also, check if the incremental files has a different schema vs the file you are using to create the table.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Follow-ups are appreciated!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 01:49:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/61302#M31757</guid>
      <dc:creator>Palash01</dc:creator>
      <dc:date>2024-02-21T01:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: DELTA_EXCEED_CHAR_VARCHAR_LIMIT</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/67409#M33336</link>
      <description>&lt;P&gt;Hi Palash,&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have Unity Catalogs created off external table locations, which are mounted to Databricks from azure DL. If a change of schema has come from upstream this causes this issue. To resolve, read in new source schema names from raw. Performed ALTER TABLE include these new columns then had to run UPDATE SET on the columns to give them an empty string ''. This then allowed for dataframe to overwrite the files in mounted storage without causing an error&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 14:43:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/67409#M33336</guid>
      <dc:creator>Paul92S</dc:creator>
      <dc:date>2024-04-26T14:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: DELTA_EXCEED_CHAR_VARCHAR_LIMIT</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/70290#M34048</link>
      <description>&lt;P&gt;Setting this config change before making the write command solved it for us:&amp;nbsp;&amp;nbsp;spark.conf.set("spark.sql.legacy.charVarcharAsString", True)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 17:29:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/70290#M34048</guid>
      <dc:creator>willflwrs</dc:creator>
      <dc:date>2024-05-22T17:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: DELTA_EXCEED_CHAR_VARCHAR_LIMIT</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/110767#M43680</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/105614"&gt;@willflwrs&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm experiencing the same thing, how to set this up &lt;SPAN&gt;spark.conf.set("spark.sql.legacy.charVarcharAsString", True&lt;/SPAN&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 15:57:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/110767#M43680</guid>
      <dc:creator>AgusBudianto</dc:creator>
      <dc:date>2025-02-20T15:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: DELTA_EXCEED_CHAR_VARCHAR_LIMIT</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/110769#M43681</link>
      <description>&lt;P&gt;Just run the command at the top of the notebook&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 16:01:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/110769#M43681</guid>
      <dc:creator>Paul92S</dc:creator>
      <dc:date>2025-02-20T16:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: DELTA_EXCEED_CHAR_VARCHAR_LIMIT</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/110770#M43682</link>
      <description>&lt;P&gt;can it be installed on SQL Warehouses on Databricks?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 16:10:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-exceed-char-varchar-limit/m-p/110770#M43682</guid>
      <dc:creator>AgusBudianto</dc:creator>
      <dc:date>2025-02-20T16:10:33Z</dc:date>
    </item>
  </channel>
</rss>

