Search code examples
mathgremlinreserved

Gremlin math step has issues if a reserved word "exp" is used in a label name


I have a query which has the math function like below,

math('number1-expected_value').next()

It throws error as

**GremlinServerError: 499: {"detailedMessage":"Unknown function or variable 'cted_value' at pos 20 in expression 'number1 - expected_value'","requestId":"01e3f9e6-3cf2-4af0-bf94-5a4979d488b4","code":"InvalidParameterException"}**

I know, the exp keyword is reserved for exponentiation operation. Is there anyone who knows how to use a keyword as a normal string inside the math function in gremlin?

Note: when I change the variable as "eexpected_value", it works. If I choose expeected_value, it throws same error. Hence expe and expee make operation of exponen


Solution

  • This appears to be an issue in the Gremlin math step which is built using EXP4J. I have opened the following Jira issue to track within the Apache TinkerPop project: https://issues.apache.org/jira/browse/TINKERPOP-2856

    For now, the best workaround as you discovered is just to avoid using variable names that contain any of the math built in function names (like exp).

    UPDATED 2023-05-11

    As of Apache TinkerPop release 3.6.3 this issue is now fixed.