OpenRefine: pow() does not throw error for extra or incorrect arguments like quotient() does
To Reproduce
Steps to reproduce the behavior:
- Open Expression Editor on existing project
- On any column use Custom Text Transform with
value.pow(2,8) - Notice the preview result of
null - Change the expression to
value.quotient(2,8) - Notice the preview result of
Error: quotient expects two numbers
Current Results
null is shown in preview result, instead of an error (since value is passed as one of the arguments with additional 2 arguments (2,8) supplied)
Expected Behavior
pow() should check arguments like quotient() does and show similar error.
Screenshots




Versions
- Operating System: Windows 10
- Browser Version: Firefox latest
- JRE or JDK Version: JDK8
- OpenRefine: openrefine-3.4-beta-458-g109aa78
Datasets
Additional context
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (18 by maintainers)
@elebitzero we can definitely work together so this can be resolved 😃😁 I’ll go through your PR and select out what is not included so I can launch my help too.
@antoine2711 @elroykanye, oops, I’m just seeing these recent comments now. It looks like I picked up this issue at the same time @elroykanye started looking into it. I should have commented on the issue first.
I fixed the issue where
null.pow(2)returns null instead of an error like all the other math functions. Also, I found thatnull.exp()returned null instead of an error. So the issue fixed by my PR is thatpow()andexp()now return Error instead of null for null arguments, so they are now consistent with the other math functions.I also added a new test
testNullArgsMathto check that the math functions return an error with null argument(s).Note: @thadguidry mentioned
value.pow(2,8)which is not valid becausepow()expects two numbers. In this case, my fix will display an error instead of null.Alright then, I will go through each and enforce the pattern of returning an EvalError if there are no objections.
Yes, it’s an error, but I think the point of the original bug report was that the error handling for the two cases should be equivalent. They should either both return error or both return null. I have a strong preference for the former.
This isn’t limited to
pow(). All of these functions are exempt from the test for too many arguments:https://github.com/OpenRefine/OpenRefine/blob/c8a721a10bbdba092b3605204aa9849da3089e5f/main/tests/server/src/com/google/refine/grel/FunctionTests.java#L133-L137
"chomp", "contains", "coalesce", "escape", "unescape", "exp", "fingerprint", "get", "now", "parseJson", "partition", "pow", "rpartition", "slice", "substring", "unicode", "unicodeType"@tfmorris or @wetneb will check (they are 2 of our core developers) as I’m staying out of active development. But I will be happy to test once merged.