lingareddy_Alva
Esteemed Contributor

Hi @Splush_ 

This is a common caching issue in Databricks when working with COPY INTO operations.
The system is holding onto metadata about the old schema location even after you've renamed it.

Clear the COPY INTO operation history:

COPY INTO {new_landing_table_name}
FROM '{file_location}'
FILEFORMAT = {file_type}
FORMAT_OPTIONS ({format_options})
COPY_OPTIONS ("force" = "true", "mergeSchema" = "true")

Root Cause Prevention
The issue occurs because COPY INTO maintains internal metadata about file processing
history tied to the table location. When you rename the schema, this metadata still references the old path.

For future schema changes:
1. Always use DROP TABLE IF EXISTS before recreating
2. Consider using CLONE operations for table migrations
3. Use the force = true option in COPY_OPTIONS to override metadata checks

Try the force = true option first, as it's the most direct solution for this specific caching issue.

LR