Value from as step suprisingly becomes null in math step

63 views
Skip to first unread message

Danial Saleem

unread,
Aug 27, 2021, 12:00:46 PM8/27/21
to Gremlin-users

So I have this query:

g.V().hasLabel('mylabel').count().as('a').V().count().math('_ - a')

which gives me this error:
The variable a for math() step must resolve to a Number - it is instead of type null with value null

even though I do set the value

Stephen Mallette

unread,
Aug 30, 2021, 8:32:37 AM8/30/21
to gremli...@googlegroups.com
The error message isn't clear but basically you can't access a path after a reducing barrier like count():

gremlin> g.V().hasLabel('person').count().as('a').V().count().select('a')
gremlin> g.V().hasLabel('person').count().as('a').V().select('a')
==>4
==>4
==>4
==>4
==>4
==>4


If you need to bring a value across the barrier you typically have to keep it as a side-effect:

gremlin> g.V().hasLabel('person').count().aggregate('a').V().count().math('_ - a').by().by(unfold())
==>2.0





 

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/aba3a286-db0d-4c4c-a08c-0fa8d941943an%40googlegroups.com.

Danial Saleem

unread,
Sep 8, 2021, 6:56:05 AM9/8/21
to Gremlin-users

thanks a lot. that did work for me.
Reply all
Reply to author
Forward
0 new messages