Column Renamer | Flow Variable | How To Rename/Overwrite a Column Name Using Flow Variable (KNIME 5.8.1 LTS)

Hello All, Hope all of you are doing well. I am stuck in a black hole.

I am using “Column Filter Configuration” and “Column Renamer” node in my use case.

I am trying to rename/Overwrite a column name using flow variables in Column Renamer node. Flow variables coming from Column Filter Configuration but not getting required flow variable in Column Renamer.

May be I am missing something. Kindly Help me to solve it or suggest me the work around.

the old renamer nodes where likely able to handle arrays (s).
the new nodes are structured differently, and backwards compatibility is currently not KNIMEs focus. (the new nodes have this ugly pattern of overly large “cards” that need to be filled with (and if you use more than 2 cards, you have to start scrolling endlessly) the modifications. and each card gets a dynamic flow variable input. but if you start changing the order or deleting a card within, everything breaks apart).

hence, instead of feeding an array, you now need to

  • be aware of the amount of columns upfront
  • build ugly loops manually iterating through the array
  • use the old nodes accessible with the //deprecated tag
  • convert the selection to a (empty table) and use the column renamer that uses a dictionary (second input)
1 Like

Hi Thanks for suggestions.

Hi @fe145f9fb2a1f6b ,

but if you start changing the order or deleting a card within, everything breaks apart).

I was not aware of this problem and haven’t found a ticket, so I created one (internal reference UIEXT-3255).

3 Likes

might not be the case anymore, I stopped actively testing and using the modern ui after 5.2 or so and have been sticking with the old ui and old nodes since then
back when you had to move to the old ui anyway if you wanted to use flowvars

1 Like

Hi @anilsknp , I agree with the sentiment that not being able to use array flow-variables in a nodes that can be manually configured dynamically to increase/reduce the number of columns or other features makes the creation of generic code challenging.

It would certainly feel like a retrograde step if it were previously possible to use arrays in the deprecated node. That being said, I have looked back as far as KNIME 4.7.8, and I didn’t find the ability even in that version to rename columns using String Array flow variables. I would be interested to know if there is an earlier version of Column Renamer that did allow array flow variables for configuration.

e.g. this is 4.7.8 UI, which as you can see also does not provide easy configuration with array variables:

For Column Renaming, probably the preferred way of renaming an arbitrary number of columns would be to use the Column Renamer (Dictionary) node. This takes a lookup (dictionary) table consisting of two columns; one which is the original name, and the second being the replacement name.

If you have two array flow variables, you can generate the required “dictionary” table as follows:

In this example demo, I have used my “Create String Array Variable” component but I would assume you already have your two array variables so you’d just need the part from “Variable to Table Row” onwards.

In the Column Renamer (Dictionary), ensure that the option to “Fail if no assignment” is turned off, which means you then only have to include columns that are to be renamed in the dictionary table.

Here is the example workflow
column renaming with flow variables.knwf (81.6 KB)

1 Like