'Sack Sum By operation causes AWS Neptune error
Problem up-front: AWS Neptune seems to break when using a .sack(__.sum).by() operation.
Background:
- Here is a small bit of data on which to test
- The query in question works fine via the Gremlin console
- I came across this tackling a larger problem, but the length of that post (and my multiple updates to it...) were burying the problem, so I'm posting this here, separately.
Conditions
- Data store: AWS Neptune
- Querying from / runtime: AWS Lambda running Node.js
Given the above, this query will execute:
return await g.withSack(120)
.V(fromPortId)
.repeat(
(__.outE().hasLabel('VOYAGES_TO'))
.inV()
.simplePath()
)
.until(
__.has('code', toPortId).and()
.sack().is(lte(travelTimeBudget))
)
.order().by(__.sack(), __.desc)
.local(
__.union(__.path().by('code')
.by('duration'), __.sack()).fold()
)
.local(
__.unfold().unfold().fold()
)
.toList()
.then(data => {
return data
})
.catch(error => {
console.log('ERROR', error);
});
... but this query will not:
return await g.withSack(120)
.V(fromPortId)
.repeat(
(__.outE().hasLabel('VOYAGES_TO').sack(__.sum).by('duration'))
.sack(__.sum).by(__.constant(45))
.inV()
.simplePath()
)
.until(
__.has('code', toPortId).and()
.sack().is(lte(travelTimeBudget))
)
.order().by(__.sack(), __.desc)
.local(
__.union(__.path().by('code')
.by('duration'), __.sack()).fold()
)
.local(
__.unfold().unfold().fold()
)
.toList()
.then(data => {
return data
})
.catch(error => {
console.log('ERROR', error);
});
... and the only difference between the two is the presence of the .sack(__.sum).by() operators.
Any thoughts or suggestions?
Solution 1:[1]
You should not use __.sum inside a sack step, as that is the actual sum() step (from the anonymous traversal __.) and not the Operator.sum enum. You should ideally include those at the top of your code, alternatively use:
(__.outE().hasLabel('VOYAGES_TO').sack(operator.sum).by('duration'))
.sack(operator.sum).by(__.constant(45))
The additional parentheses around this block of code should also not be needed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dan |
