<?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 handle changing column data types in Auto Loader? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/178005#M57454</link>
    <description>&lt;P&gt;Parquet files carry their own &lt;STRONG&gt;schema&lt;/STRONG&gt; inside them - every file knows what type each column is. When Auto Loader started the stream, it sampled the first files it saw, found id as INT and &lt;STRONG&gt;locked&lt;/STRONG&gt; that schema in (stores it under a _schemas directory in the schema location so it can track changes over time). Every file after that gets read &lt;EM&gt;against&lt;/EM&gt; that locked schema. So when new Parquet files show up with id as a string, the reader finds it as a mismatch. The key thing is - Auto Loader treats a type mismatch as &lt;EM&gt;&lt;STRONG&gt;rescuable&lt;/STRONG&gt; data&lt;/EM&gt;&amp;nbsp;not as a corrupt record or an error. Hence the pipeline generally does not crash - the value in the typed column becomes NULL and the original value gets safely tucked into &lt;STRONG&gt;_rescued_data&lt;/STRONG&gt; as a JSON blob (also records which file it came from). Note that int to string is &lt;EM&gt;not&lt;/EM&gt; a widening change (unlike int to long or float to double), so even the newest automatic type widening feature cannot silently evolve the column - it would also route those values to _rescued_data.&lt;/P&gt;&lt;P&gt;You can follow below&lt;/P&gt;&lt;P&gt;Confirm with the &lt;STRONG&gt;upstream team&lt;/STRONG&gt; that the change is &lt;STRONG&gt;intentional&lt;/STRONG&gt; and permanent - if it's a bug on their side, fixing it there is the right option. If it's permanent, two things need to happen. On the &lt;STRONG&gt;read&lt;/STRONG&gt; side, add a &lt;A href="https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/type-widening/" target="_self"&gt;&lt;STRONG&gt;schema hint&lt;/STRONG&gt;&lt;/A&gt; so Auto Loader reads the column as a &lt;STRONG&gt;string&lt;/STRONG&gt; going forward - like .option("cloudFiles.schemaHints", "id string"). Note that with Parquet, a hint is not a cast - it tells the Parquet reader to read the column as that type. On the &lt;STRONG&gt;write&lt;/STRONG&gt; side, the Delta table still has the column as INT and since int to string is an incompatible type change for a Delta table, you need to handle the table side deliberately - by writing to a fresh table with the new schema and switching over, or backfilling after recreating the table or casting in a downstream layer if you would like to keep the raw table as is. &lt;STRONG&gt;Restart&lt;/STRONG&gt; the stream (schema changes are picked up at stream start). Lastly, don't forget the data that was rescued while the mismatch was live - those rows can be found in _rescued_data and you can reprocess or backfill them from the source files so nothing is lost.&lt;/P&gt;</description>
    <pubDate>Sun, 29 Nov 2026 11:38:16 GMT</pubDate>
    <dc:creator>balajij8</dc:creator>
    <dc:date>2026-11-29T11:38:16Z</dc:date>
    <item>
      <title>How to handle changing column data types in Auto Loader?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/177897#M57410</link>
      <description>&lt;P&gt;&lt;SPAN&gt;How do you handle a situation where an upstream system suddenly changes the data type of an existing column?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, a column that was originally an integer starts arriving as a string in new Parquet files.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What is the best way to handle these files without stopping the entire ingestion pipeline? Can schema hints or rescued data columns help in this situation?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Nov 2026 09:49:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/177897#M57410</guid>
      <dc:creator>angelinak</dc:creator>
      <dc:date>2026-11-28T09:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle changing column data types in Auto Loader?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/177965#M57435</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/274870"&gt;@angelinak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Auto Loader's schema evolution only adds new columns. It doesn't change an existing column's type. With the rescued data column (on by default when Auto Loader infers the schema), a value whose type doesn't match the schema is set to null in its column and saved in _rescued_data, so the stream keeps running. Keep the column at its intended type with a schema hint, then repair or quarantine the rescued values downstream.&lt;/P&gt;&lt;P&gt;bronze = (spark.readStream.format("cloudFiles")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.option("cloudFiles.format", "parquet")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.option("cloudFiles.schemaLocation", "/Volumes/.../_schemas/orders")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.option("cloudFiles.schemaHints", "quantity INT")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.option("rescuedDataColumn", "_rescued_data")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.load("/Volumes/.../landing/orders/"))&lt;/P&gt;&lt;P&gt;Downstream (silver), recover what you can and quarantine the rest:&lt;/P&gt;&lt;P&gt;from pyspark.sql import functions as F&lt;/P&gt;&lt;P&gt;rescued = F.get_json_object("_rescued_data", "$.quantity")&lt;/P&gt;&lt;P&gt;silver = (bronze&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.withColumn("quantity", F.coalesce(F.col("quantity"), rescued.try_cast("int")))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.withColumn("_bad_quantity", F.col("quantity").isNull() &amp;amp; rescued.isNotNull()))&lt;/P&gt;&lt;P&gt;Rows where _bad_quantity is true (for example "12 units") can go to a quarantine table instead of failing the load. _rescued_data also records the source file path, so you can tell the upstream team exactly which files changed.&lt;/P&gt;&lt;P&gt;Answers to your two questions:&lt;/P&gt;&lt;P&gt;- Schema hints: yes. They pin the expected type so inference doesn't flip the column to string. On their own they don't fix the bad values.&lt;/P&gt;&lt;P&gt;- Rescued data column: yes. It's what keeps the pipeline running. Without it, a type mismatch fails the stream.&lt;/P&gt;&lt;P&gt;If the change is permanent (the column really is a string now), change the target column on purpose: add a new column or rewrite the table. Delta type widening only covers safe changes like INT to BIGINT, not INT to STRING.&lt;/P&gt;&lt;P&gt;Docs: &lt;A href="https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/schema#rescued-data-column" target="_blank"&gt;https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/schema#rescued-data-column&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Nov 2026 20:01:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/177965#M57435</guid>
      <dc:creator>SumeshKashyap</dc:creator>
      <dc:date>2026-11-28T20:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle changing column data types in Auto Loader?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/177998#M57447</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Yes, schema hints and rescued data columns can help, but it is important to distinguish schema evolution from data type conversion.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Changing an existing column from integer to string is not a supported automatic type-widening operation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;1. Use rescue mode to maintain uninterrupted ingestion&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;df = (
    spark.readStream
    .format("cloudFiles")
    .option("cloudFiles.format", "parquet")
    .option("cloudFiles.schemaLocation", schema_path)
    .option("cloudFiles.schemaEvolutionMode", "rescue")
    .option("rescuedDataColumn", "_rescued_data")
    .load(source_path)
)&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Incompatible fields can be captured in &lt;/SPAN&gt;&lt;SPAN&gt;_rescued_data&lt;/SPAN&gt;&lt;SPAN&gt; without automatically changing the existing schema.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;2. Standardize data types in the Silver layer&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, if &lt;/SPAN&gt;&lt;SPAN&gt;customer_id&lt;/SPAN&gt;&lt;SPAN&gt; was originally an integer but starts arriving as a string such as &lt;/SPAN&gt;&lt;SPAN&gt;CUST101&lt;/SPAN&gt;&lt;SPAN&gt;, you can recover and standardize the value:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;from pyspark.sql import functions as F

df = df.withColumn(
    "customer_id",
    F.coalesce(
        F.col("customer_id").cast("string"),
        F.get_json_object(
            "_rescued_data", "$.customer_id"
        )
    )
)&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;3. Understand schema hint limitations&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Schema hints for Parquet instruct the reader how to interpret a column. They do not automatically cast incompatible physical data types.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My recommendation is to preserve unexpected data in the Bronze layer, standardize data types in the Silver layer and configure alerts whenever &lt;/SPAN&gt;&lt;SPAN&gt;_rescued_data&lt;/SPAN&gt;&lt;SPAN&gt; contains values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This keeps ingestion resilient while maintaining downstream data quality. The example assumes the rescued JSON contains the incompatible field.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Official references:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/schema?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;Auto Loader schema inference and evolution&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/data-engineering/schema-evolution?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;Schema evolution in Databricks&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/delta/type-widening?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;Delta Lake type widening&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 29 Nov 2026 07:49:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/177998#M57447</guid>
      <dc:creator>tajamulkhan</dc:creator>
      <dc:date>2026-11-29T07:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle changing column data types in Auto Loader?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/178005#M57454</link>
      <description>&lt;P&gt;Parquet files carry their own &lt;STRONG&gt;schema&lt;/STRONG&gt; inside them - every file knows what type each column is. When Auto Loader started the stream, it sampled the first files it saw, found id as INT and &lt;STRONG&gt;locked&lt;/STRONG&gt; that schema in (stores it under a _schemas directory in the schema location so it can track changes over time). Every file after that gets read &lt;EM&gt;against&lt;/EM&gt; that locked schema. So when new Parquet files show up with id as a string, the reader finds it as a mismatch. The key thing is - Auto Loader treats a type mismatch as &lt;EM&gt;&lt;STRONG&gt;rescuable&lt;/STRONG&gt; data&lt;/EM&gt;&amp;nbsp;not as a corrupt record or an error. Hence the pipeline generally does not crash - the value in the typed column becomes NULL and the original value gets safely tucked into &lt;STRONG&gt;_rescued_data&lt;/STRONG&gt; as a JSON blob (also records which file it came from). Note that int to string is &lt;EM&gt;not&lt;/EM&gt; a widening change (unlike int to long or float to double), so even the newest automatic type widening feature cannot silently evolve the column - it would also route those values to _rescued_data.&lt;/P&gt;&lt;P&gt;You can follow below&lt;/P&gt;&lt;P&gt;Confirm with the &lt;STRONG&gt;upstream team&lt;/STRONG&gt; that the change is &lt;STRONG&gt;intentional&lt;/STRONG&gt; and permanent - if it's a bug on their side, fixing it there is the right option. If it's permanent, two things need to happen. On the &lt;STRONG&gt;read&lt;/STRONG&gt; side, add a &lt;A href="https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/type-widening/" target="_self"&gt;&lt;STRONG&gt;schema hint&lt;/STRONG&gt;&lt;/A&gt; so Auto Loader reads the column as a &lt;STRONG&gt;string&lt;/STRONG&gt; going forward - like .option("cloudFiles.schemaHints", "id string"). Note that with Parquet, a hint is not a cast - it tells the Parquet reader to read the column as that type. On the &lt;STRONG&gt;write&lt;/STRONG&gt; side, the Delta table still has the column as INT and since int to string is an incompatible type change for a Delta table, you need to handle the table side deliberately - by writing to a fresh table with the new schema and switching over, or backfilling after recreating the table or casting in a downstream layer if you would like to keep the raw table as is. &lt;STRONG&gt;Restart&lt;/STRONG&gt; the stream (schema changes are picked up at stream start). Lastly, don't forget the data that was rescued while the mismatch was live - those rows can be found in _rescued_data and you can reprocess or backfill them from the source files so nothing is lost.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2026 11:38:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-handle-changing-column-data-types-in-auto-loader/m-p/178005#M57454</guid>
      <dc:creator>balajij8</dc:creator>
      <dc:date>2026-11-29T11:38:16Z</dc:date>
    </item>
  </channel>
</rss>

