Create column if it doesn't exist


I need to create a column if it doesn’t exist, I saw the topic I take the first solution with the “either table” it works but it adds complexity to implement and I don’t found to make it generic (for example if I have several columns to create I need to copy again this bloc as much as I have columns)

My questions are :

  • how to make this solution generic ?
  • Maybe a more simple solution is possible ? (I try simply to add a new column with a if() inside but my prb is I need to export a final file without this column at the end. If the column already exists I obtain a “newColumn2” and I need to remove it in a action, therefore an error occurs if “newColumn2” doesn’t exist)

Hi @ivankee and welcome to the Community!

I would suggest using the 2nd approach as it's simpler.

If you have several column to create, you can calculate them in a separate table and append all at once with the "Append" action in the "Append columns mode". In this case, only the "Append" action will be after the "Skip" action.

How generic it should be?

Put the action that removes "newColumn2" after the "Skip" action and execute it only when "newColumn2" exists.

Thank you @dgudkov for the answer.
Finally, I decided to use the second approach with the skip and an if columnexist(“newColumn2”) like you advised.

Thank you so much !

You’re welcome :slight_smile: