Column Expression node?

Hi,

I have to create a new calculated column based on a formula applied to a column from my input table. The formula is not fixed; the user specifies this formula at the execution time. I thought I could do this with a column expressions node but I was unsuccessful.

Do you have an idea on how I could do this?

Thanks,

Claire

Hi Claire,
you can handle this by using a component:
image

In the string configuration you have to write the exact formula to use and pass it by a flow variable to the column expression node, like this:
image

By double clicking on the component, this popup come out, where you write the formula:
image

Hope it helps.

Luca

3 Likes

Thanks a lot Luca, I was using my variable in the wrong place.
Great, it works,
Regards,
Claire

4 Likes

Hi,
Do you know if there is a node that checks if the formula is correct? Right now, if it is not the case, I just get a warning.
Thanks,
Claire

You can maybe use a try/catch node:
image
but i get always an error on expression node whenever i intentionally put synthax errors in the string widget… someone can help pls?

Luca

Hello,

well String Configuration node has Regular Expression field so one can write regex to validate given expression.

Br,
Ivan

Some examples pls? :innocent:

Hi @Luca_Italy,

not a regex expert but something like this if you only want expression to be about adding two numbers:
\d+[+-]\d+

More complex expressions obviously lead to more complex regex…

Br,
Ivan

ok, clear.
but you can’t really check if the syntax is correct or not.

Nop. There is no “JavaScript syntax checker” outside of Column Expressions and to my knowledge not sure how to simulate one.
Ivan

So there isn’t a way to bypass a node if something wrote in a string widget is wrong?
I can’t figure out

Luca

For checking regular expressions on the fly, you might try out the RegEx Extractor node from the Palladian extension.

i don’t think that might be the solution of this usecase.
i’ll want to simply bypass a node that has been put “down” because a string configurator node is injecting a wrong formula. Can some try/catch node resolve this issue?

Hello @Luca_Italy,

I understand but that is not possible with Try/Catch nodes cause they catch errors during execution while Column Expressions throws error during configuration in this case.

Br,
Ivan

Exactly. But maybe i’ve found a way to bypass a configuration error of that node.
Look at this:

And this is the nested component, where column expression is:

image

So when i write this in the master component:
image

i can successfully bypass the node and getting an error both as breakpoint and as custom message from the table.

Luca

2 Likes

Hello @Luca_Italy,

nice one :+1:

Looking from a use case perspective. If a user inputs wrong expression workflow can continue to execute but results are not going to be correct. This means user has to run workflow again and again until expression is right. So if I’m designer or user running workflow I would prefer to throw/have syntax error right away and not wait till execution is done, then check results and go back to same workflow…

Br,
Ivan

yep, that’s true. only testing/prototyping here :wink:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.