Suggestion: Support more Flow Variable data types in Java scripting

Hello again,
the Java scripting nodes can currently only work with 3 types of Flow Variables: int, double, string. Other data types exist (long, bool, Path, array variables, …) but they’re only compatible with Java scripting as Columns.
Accessing those Flow Variables via code doesn’t work: getFlowVariable("myLong", tLong) only gives the error message “The flow variable with name “myLong” does not exist”. Doing getCell("myLong", tLong) works however.
This feels like an artificial restriction to me, but maybe there’s a reason for this?

There’re workarounds for these limitations, but it would make the Java scripting more powerful if it could read and write all Flow Variable data types.

Btw, getCell("myPath", FSLocation) does not work, because “FSLocation” cannot be resolved to a variable. Maybe someone has the right type for me to put in?
Manually doing import org.knime.filehandling.core.connections.FSLocation; also doesn’t work. Usually it’s redundant because using a Path column as input or output will automatically add it to the imports, but if getting path cell values programmatically would work, then this would be a problem.

Node description listing all the methods to arbitrarily access columns and variables. It’s from v2.8.0, but the relevant section hasn’t changed since then:
Node description for Java Snippet (knime.com)
Somewhat related bug-thread from a year ago:
“Table Row To Variable” variables not accessible

2 Likes

I just found out that the String Manipulation nodes (table, multi, variable) also cannot access neither Bool, Long, Path and array variables. This is probably true for several more nodes.

There’s more: All of this applies only to the main configuration window. In the Flow Variables tab, all of the mentioned variable types are there (when the type fits of course). (for all nodes mentioned so far)

1 Like

A bit odd is that, as @Thyme already mentioned, nodes like the String Manipulation node cannot handle type Long (or Integer, or Double) flow variables, but have no problem handling type Long (or Integer, or Double) table columns…

A related thing is that one would naively assume that every available table column type is also available as a flow variable type, but this is not the case.

Consider the following table for example:

image

When trying to convert these to flow variables, columns 1-5 work fine. However, the SMILES column is converted to a regular String flow variable, and column 7 (containing a list of an integer and a string) gives an error message:

Is there a certain rationale that dictates which column types are available as flow variables and from where these can be accessed?

Best
Aswin

1 Like

Hello @Aswin and thanks for joining me. I tried to recreate the error, but the best I can do is a warning. The Table Row to Variable happily executes, but doesn’t create the Flow Variable:
WARN Table Row to Variable 3:6 Can not convert cell with List of DataCell type to a flow variable. (Column "Row0" at offset 0)
Unbenannt
I thought maybe you used the Table Column to Variable node, but that one also does only a warning:

WARN Table Column to Variable 3:7 Input contains no column that can be converted to a flow variable

At least I found a list of supported Flow Variables when I tried to configure the Table Column to Variable node. Apparently it’s Bool, Int, Long, Double, String, their array counterparts, and Path:
tmp2
That explains why some of the column types are converted to String. In this companion thread I found out that the Date&Time types are converted to String, today I added XML to the list. Lists/Sets of mixed type can not be mapped to any of those types. String array would work, but only with information loss.
tmp.knwf (16.9 KB)

1 Like

Hi @Thyme

thank you for providing your example workflow, in my setup it gives the same error that I had before with my example workflow, so probably it is a change in behavior between my KNIME version (4.3.4) and yours (4.5.1). (I am still on the old one because I understood that a lot has changed in the Python support). But fact is, neither version can create a flow variable out of this column.

Best,
Aswin

1 Like