Column Expressions node with Null Pointer Exception

I get a (“NullPointerException”): null when executing column expression.
I am using regexReplace command in it.
What am I doing wrong?

Hi @IrynaK -

I believe this means that you are trying to execute your RegEx on null values in your dataset. If you fill in the null values, or remove those records, does the error persist?

1 Like

@IrynaK this is new for us, and should not happen.
Would it be possible that you make us a minimal workflow which demonstrates the problem?

(I also moved your question into a seperate topic)

Hello Iris,
Sorry, it took a while. I came across the same issue during a different workflow. The workflow itself is big, however the error happens in Node 142 for the 3rd row of the sample data.Commodity Tax Validator - QST.knwf (119.9 KB)

Hi,

As @ScottF mentioned, you are applying the regex matcher on a missing value. Here is a fix:

if (column("Status") == null) {"Invalid"}
else if (regexMatcher(column("Status"),"Valid.*"))
{"Valid"}
else
{"Invalid"}

Replace this with the current expression for the “status” column and the problem is solved.

:blush:

2 Likes

Hi IrynaK

As mentioned before, you are using your regexmatcher function in a column containing missing values. You could first need to check for missing values in your column: @armingrudd solution works perfectly in this case! Just as another option to achieve the same is to use the isMissing function (under the Logical category) and check it in a similar way @armingrudd does.

Both options would do the same thing. :slight_smile:

3 Likes

Thank you guys. Applied your fix and it works!

2 Likes