Context:
Delta Lake allows developers to merge data into a table with something called a Merge Statement. I am using Delta Lake's Change Data Feed feature to determine whether I want to insert, update, or delete a certain row. This is determined by the value of the column _change_type, which is created by Delta Lake.
The Problems:
It is easy to use the _change_type column inside the Merge Condition, in order to determine what to do with each row. The problem is that if I use this column inside the merge condition it will be inserted into my target table, along with the rest of the data. I don't want my target table to contain this _change_type column, as it is useless and can create conflicts if I decide to use Change Data Feed on the target table too.
Additional Notes:
I am aware that it is possible to solve this issue by fixating the schema of the target table, however, I need to support schema evolution on the target table, as such, I can't do this. Ideally, I would be able to drop the _change_type column after checking the merge condition, but before actually merging into the table. Is something like this possible?