0

In NeptuneDB, I wanna check if one specific vertex exist or not, if not, create it and add some properties. Here is my implementation in Gremlin Python:

g.V().hasLabel('Event').has(T.id, idNum).fold().coalesce(unfold(), addV('Event').property(T.id, idNum)). property(Cardinality.single, 'semState', event['semState']).property(Cardinality.single, 'System', systemname).next()

but sometime the 'System' property can be null, in this case, error was thrown. So I was wondering if there is a way to check if 'System' is null in the query above, if null, skip it.

Hongli Bu
  • 461
  • 12
  • 37

1 Answers1

2

Gremlin doesn't like null values, so the solution should be on the client side, by splitting the query:

query = g.V().hasLabel('Event').has(T.id, idNum).fold().coalesce(unfold(), addV('Event').property(T.id, idNum)). property(Cardinality.single, 'semState', event['semState'])
if systemname is not None:
    query = query.property(Cardinality.single, 'System', systemname)
query.next()
Kfir Dadosh
  • 1,411
  • 9
  • 9