northwesternmutual / grammes

A Go package built to communicate with Apache TinkerPop™ Graph computing framework using Gremlin; a graph traversal language used by graph databases such as JanusGraph®, MS Cosmos DB, AWS Neptune, and DataStax® Enterprise Graph.
Apache License 2.0
125 stars 45 forks source link

json unmarshal error on AddVertex #5

Closed nphase closed 4 years ago

nphase commented 5 years ago

json: cannot unmarshal number into Go struct field PropertyID.@value of type model.PropertyIDValue

using AddVertexByQuery() on 1.1.0

Occurs with client.AddVertexByQuery(g.AddV("person").Property("name", "damien")) as well as client.AddVertex("person")

damienstamates commented 5 years ago

@nphase I'm unable to replicate the results you're running into. What database are you using?

nphase commented 5 years ago

I'm using 3.4.2 of gremlin server based on this docker image: https://github.com/bricaud/gremlin-server on but I get the same error when interacting with AWS Neptune.

I will try to debug grammes tomorrow and see if I can find the source of the issue. Thanks for your help!

damienstamates commented 5 years ago

@nphase there is no immediate support for AWS Neptune in Grammes, unfortunately.

When Grammes was released I was pulled doing other projects. The support for Databases besides JanusGraph isn't officially supported. If you want to help out with support then by all means. For the time being, I have no immediate plans to support other platforms due to time restraints.

Most time with graph databases in my work revolves around Dgraph now due to its superiority in query speeds. I recommend checking out quirk if you want a nice client for it that I'm currently maintaining myself.

shutcode commented 5 years ago

Dgraph has no spark connector

damienstamates commented 4 years ago

Closing due to age.

brugnara commented 4 years ago

Hi.

I have this very issue.

It seems to be related to the vertex ID when it is of a different type from an integer. This is easily reproducible, with TinkerPop Gremlin server, changing the file conf/tinkergraph-empty.properties and replacing:

gremlin.tinkergraph.vertexIdManager=LONG

with:

gremlin.tinkergraph.edgeIdManager=UUID
gremlin.tinkergraph.vertexIdManager=UUID
gremlin.tinkergraph.vertexPropertyIdManager=UUID

Then restart the local-server with cd bin && ./gremlin-server.sh stop && ./gremlin-server.sh start

The "incriminated" could be this, in where we are expecting the ID to be a int64. In order to support the UUID form, this should be changed. I'll happily help but any suggestion by the authors will be very appreciated :)

package model

// ID contains the data stores in the
// 'ID' data including the type and Value
type ID struct {
    Type  string `json:"@type"`
    Value int64  `json:"@value"`
}

Let me also thank you for this library.

PS: consider my fork where I'm trying to patch your lib. At the time of writing, it is accepting UUID ids... Will fix tests and will do a deep try before screaming for victory. :)

GerryLon commented 1 year ago

@damienstamates help please!

vertex added success, but return err.

image

2023-01-30T21:57:15.938+0800    debug   logging/debuglogger.go:46       [Grammes]       {"query": "g.addV(\"Node\").property(\"node_id\",\"staff:123456\").property(\"node_type\",\"staff\").property(\"name\",\"demo\").property(\"display_name\",\"demo\")"}
2023-01-30T21:57:15.941+0800    debug   logging/debuglogger.go:65       authenticate: Prepared authentication request
2023-01-30T21:57:15.974+0800    error   logging/debuglogger.go:51       vertices unmarshal      {"error": "{\"type\":\"UNMARSHAL_ERROR\"},{\"function\":\"AddVertexByString\"},{\"rawBytes\":\"{\"@type\":\"g:List\",\"@value\":[{\"@type\":\"g:List\",\"@value\":[{\"@type\":\"g:Vertex\",\"@value\":{\"id\":\"staff:123456\",\"label\":\"Node\",\"properties\":{\"display_name\":[{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":\"demo\",\"label\":\"display_name\",\"value\":\"demo\"}}],\"name\":[{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":\"demo\",\"label\":\"name\",\"value\":\"demo\"}}],\"node_type\":[{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":\"staff\",\"label\":\"node_type\",\"value\":\"staff\"}}]}}}]}]}\"},{\"error\":\"json: cannot unmarshal array into Go struct field Vertex.@value of type model.VertexValue\"}"}
github.com/northwesternmutual/grammes/logging.(*DebugLogger).Error
        /Users/gerrylon/workspace/gopath/pkg/mod/github.com/northwesternmutual/grammes@v1.2.0/logging/debuglogger.go:51
github.com/northwesternmutual/grammes/manager.(*addVertexQueryManager).AddVertexByString
        /Users/gerrylon/workspace/gopath/pkg/mod/github.com/northwesternmutual/grammes@v1.2.0/manager/addvertex.go:152
github.com/northwesternmutual/grammes/manager.(*addVertexQueryManager).AddVertex
        /Users/gerrylon/workspace/gopath/pkg/mod/github.com/northwesternmutual/grammes@v1.2.0/manager/addvertex.go:108
konis-cli/pkg/konis.(*KonisCli).AddVertex
        /Users/gerrylon/workspace/xxxxxxxxx/go/gerrylonwan/awesome-scripts/misc/konis-cil/pkg/konis/cli.go:101
konis-cli/cmd.importVertexFromFile
        /Users/gerrylon/workspace/xxxxxxxxx/go/gerrylonwan/awesome-scripts/misc/konis-cil/cmd/import.go:237
konis-cli/cmd.glob..func1
        /Users/gerrylon/workspace/xxxxxxxxx/go/gerrylonwan/awesome-scripts/misc/konis-cil/cmd/import.go:52
github.com/spf13/cobra.(*Command).execute
        /Users/gerrylon/workspace/gopath/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920
github.com/spf13/cobra.(*Command).ExecuteC
        /Users/gerrylon/workspace/gopath/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044
github.com/spf13/cobra.(*Command).Execute
        /Users/gerrylon/workspace/gopath/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
konis-cli/cmd.Execute
        /Users/gerrylon/workspace/xxxxxxxxx/go/gerrylonwan/awesome-scripts/misc/konis-cil/cmd/root.go:41
main.main
        /Users/gerrylon/workspace/xxxxxxxxx/go/gerrylonwan/awesome-scripts/misc/konis-cil/main.go:11
runtime.main
        /opt/soft/go/src/runtime/proc.go:250