Reference error in Column Expressions

Hello, I was trying to construct an expression with intermediate variables and I have a reference error that is displayed.

The expression is the following:

c1 = column(“column1”)
*(c1 + column(“column2”))2

Note that if I write 2(c1 + column(“column2”))* the evaluation is performed without problem. Is there some issue when parsing the expression?

Hi there @gnangnan,

welcome to KNIME Community!

Would say there is no parsing issue but not a JavaScript expert. Add ; after first line or add assignment operator to second line and works like a charm :wink:

c1 = column(“column1”);
(c1 + column(“column2”))*2

OR

c1 = column(“column1”)
d2 = (c1 + column(“column2”))*2

Br,
Ivan

1 Like

Thanks @ipazin. It seems indeed to stick to the JavaScript automatic semicolon insertion.

2 Likes

Hi,

double checked your example and it seems that the parentheses around (c1 + column("column2"))*2 are associated with the first line.
I’m no JavaScript expert myself, but this could be due to the fact that column("column1") itself could return another column that you could use.

To test that behavior I’ve written a small example for the Column Expressions node:

function a(){
    return function b(a) {
        return a + 3;
    }
}

a()
(3+4)

The result I’ve obtain is 10, since a() returns function b and it gets feeded with the input 7.

Hope that helps to understand everything a bit.

Cheers,
Moritz

2 Likes