gremlin-go, MergeE, and Neptune

I couldn't find a good example for using the MergeE step without having the IDs of the vertices. I've tried different variations, but this is the current state of the query I am running:
var g *gremlingo.GraphTraversal
// ...
g.MergeV(map[interface{}]interface{}{
gremlingo.T.Label: "thing",
"name": "ABC123",
})
// ...
g.MergeE(map[interface{}]interface{}{
gremlingo.T.Label: "connect",
gremlingo.Direction.From: gremlingo.T__.V().Has("thing", "name", "ABC123").Id(),
gremlingo.Direction.To: gremlingo.T__.V().Has("thing", "name", "ABC456").Id(),
})
var g *gremlingo.GraphTraversal
// ...
g.MergeV(map[interface{}]interface{}{
gremlingo.T.Label: "thing",
"name": "ABC123",
})
// ...
g.MergeE(map[interface{}]interface{}{
gremlingo.T.Label: "connect",
gremlingo.Direction.From: gremlingo.T__.V().Has("thing", "name", "ABC123").Id(),
gremlingo.Direction.To: gremlingo.T__.V().Has("thing", "name", "ABC456").Id(),
})
The MergeV and the MergeE are being combined in a single query. The output from Neptune is the following:
E0502: error in read loop, error message '{code:87 message:{"code":"InternalFailureException","requestId":"<omitted>","detailedMessage":"null: .mergeE(LinkedHashMap)"} attributes:map[]}'. statusCode: 87
E0502: error in read loop, error message '{code:87 message:{"code":"InternalFailureException","requestId":"<omitted>","detailedMessage":"null: .mergeE(LinkedHashMap)"} attributes:map[]}'. statusCode: 87
Does anyone know what this error means? Additionally, I'm pretty sure there's something wrong with my query, but I can't seem to figure it out. If anyone knows what the problem is, please let me know.
5 Replies
trevorkropp
trevorkroppOP2y ago
I wanted to provide an update. I found an example that seemed relevant, but it doesn't seem to work. Here is the example from the TinkerPop documentation:
gremlin> g.mergeV([(T.id):1,(T.label):'Dog',name:'Toby']).as('Toby').
mergeV([(T.id):2,(T.label):'Dog',name:'Brandy']).as('Brandy').
mergeE([(T.label):'Sibling',created:'2022-02-07',(from):Merge.outV,(to):Merge.inV]).
option(Merge.outV, select('Toby')).
option(Merge.inV, select('Brandy'))
==>e[2][1-Sibling->2]
gremlin> g.E().elementMap()
==>[id:2,label:Sibling,IN:[id:2,label:Dog],OUT:[id:1,label:Dog],created:2022-02-07]
gremlin> g.mergeV([(T.id):1,(T.label):'Dog',name:'Toby']).as('Toby').
mergeV([(T.id):2,(T.label):'Dog',name:'Brandy']).as('Brandy').
mergeE([(T.label):'Sibling',created:'2022-02-07',(from):Merge.outV,(to):Merge.inV]).
option(Merge.outV, select('Toby')).
option(Merge.inV, select('Brandy'))
==>e[2][1-Sibling->2]
gremlin> g.E().elementMap()
==>[id:2,label:Sibling,IN:[id:2,label:Dog],OUT:[id:1,label:Dog],created:2022-02-07]
I adjusted my query to match it:
var g *gremlingo.GraphTraversal
// ...
g.MergeV(map[interface{}]interface{}{
gremlingo.T.Label: "thing",
"name": "ABC123",
}).As("ABC123")
// ...
g.
MergeE(map[interface{}]interface{}{
"(T.label)": "connect",
"(Direction.from)": gremlingo.Merge.OutV,
"(Direction.to)": gremlingo.Merge.InV,
}).
Option(gremlingo.Merge.OutV, gremlingo.T__.Select("ABC123")).
Option(gremlingo.Merge.InV, gremlingo.T__.Select("ABC456"))
var g *gremlingo.GraphTraversal
// ...
g.MergeV(map[interface{}]interface{}{
gremlingo.T.Label: "thing",
"name": "ABC123",
}).As("ABC123")
// ...
g.
MergeE(map[interface{}]interface{}{
"(T.label)": "connect",
"(Direction.from)": gremlingo.Merge.OutV,
"(Direction.to)": gremlingo.Merge.InV,
}).
Option(gremlingo.Merge.OutV, gremlingo.T__.Select("ABC123")).
Option(gremlingo.Merge.InV, gremlingo.T__.Select("ABC456"))
The new error is:
{code:243 message:{"code":"InvalidParameterException","requestId":"<omitted>","detailedMessage":"Cannot instantiate MaterializedValue from type: class org.apache.tinkerpop.gremlin.process.traversal.Merge"} attributes:map[]}'. statusCode: 243
{code:243 message:{"code":"InvalidParameterException","requestId":"<omitted>","detailedMessage":"Cannot instantiate MaterializedValue from type: class org.apache.tinkerpop.gremlin.process.traversal.Merge"} attributes:map[]}'. statusCode: 243
The client logs the following bytecode:
Client invoked Submit with bytecode argument: {sourceInstructions:[] stepInstructions:[{operator:mergeV arguments:[map[label:bank name:ABC123]]} {operator:as arguments:[ABC123]} {operator:mergeV arguments:[map[label:bank name:ABC456]]} {operator:as arguments:[ABC456]} {operator:mergeE arguments:[map[(Direction.from):outV (Direction.to):inV (T.label):connect]]} {operator:option arguments:[outV 0xc000074600]} {operator:option arguments:[inV 0xc000074680]} {operator:none arguments:[]}] bindings:map[]}
Client invoked Submit with bytecode argument: {sourceInstructions:[] stepInstructions:[{operator:mergeV arguments:[map[label:bank name:ABC123]]} {operator:as arguments:[ABC123]} {operator:mergeV arguments:[map[label:bank name:ABC456]]} {operator:as arguments:[ABC456]} {operator:mergeE arguments:[map[(Direction.from):outV (Direction.to):inV (T.label):connect]]} {operator:option arguments:[outV 0xc000074600]} {operator:option arguments:[inV 0xc000074680]} {operator:none arguments:[]}] bindings:map[]}
spmallette
spmallette2y ago
What version of Neptune are you using? anyone with @neptune know what's happening here? I don't recognize that error at all
trevorkropp
trevorkroppOP2y ago
This is for version 1.2.1.0 of Neptune. The latest error seems like it might be a problem with gremlin-go, since the bytecode has memory addresses, instead of select queries.
Valentyn Kahamlyk
Hi @trevorkropp Small issue in MergeE part, for me works <-g. MergeV(map[interface{}]interface{}{ gremlingo.T.Label: "thing", "name": "ABC123", }).As("ABC123"). MergeV(map[interface{}]interface{}{ gremlingo.T.Label: "thing", "name": "ABC456", }).As("ABC456"). MergeE(map[interface{}]interface{}{ gremlingo.T.Label: "connect", gremlingo.Direction.Out: gremlingo.Merge.OutV, gremlingo.Direction.In: gremlingo.Merge.InV, }). Option(gremlingo.Merge.OutV, gremlingo.T__.Select("ABC123")). Option(gremlingo.Merge.InV, gremlingo.T__.Select("ABC456")). Iterate()
trevorkropp
trevorkroppOP2y ago
@valentyn_kahamlyk Thanks, that worked! It seems using the right constants is the way to do it.
Want results from more Discord servers?
Add your server