trevorkropp
trevorkropp
ATApache TinkerPop
Created by trevorkropp on 6/8/2023 in #questions
gremlin-go, MergeE, and Neptune
@valentyn_kahamlyk Thanks, that worked! It seems using the right constants is the way to do it.
9 replies
ATApache TinkerPop
Created by trevorkropp on 6/8/2023 in #questions
gremlin-go, MergeE, and Neptune
The latest error seems like it might be a problem with gremlin-go, since the bytecode has memory addresses, instead of select queries.
9 replies
ATApache TinkerPop
Created by trevorkropp on 6/8/2023 in #questions
gremlin-go, MergeE, and Neptune
This is for version 1.2.1.0 of Neptune.
9 replies
ATApache TinkerPop
Created by trevorkropp on 6/8/2023 in #questions
gremlin-go, MergeE, and Neptune
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[]}
9 replies