azure-cosmosdb-gremlinapigremlinpython

Gremlin Query always returns: unhashable type: 'list'


Using gremlinpython==3.7.0 per this Azure Doc, No matter what query I submit, the response is always "unhashable type: 'list'"

Unless the query results are empty, then it works fine.

Example 1 (query with no results):

query = f"g.V().has('label,'notareallabel')"
results = c.submit(query)
res = results.all().result()

returns [], because there is no node with that label.

However if I run

query = f"g.V().has('label,'tank')"
results = c.submit(query)
res = results.all().result()

the results are "unhashable type: 'list'". I can confirm that this query would run by running it in the portal: enter image description here

Obviously, the returned values is a list of two object. So it wouldn't surprise me that it is a list. But Gremlinpython doesn't parse it. Is there some way to make Gremlinpython expect a list? I've already tried all variants of values valuemap and other ways to format, but because the results I want are a list, it isn't parsing them.


Solution

  • Not the best solution, but after much troubleshooting I found that it will work if you cast specific values, but not if you leave it open.

    For example:

    g.V().has('lable,'tank').valueMap()
    

    will return "unhashable type: 'list'"

    However:

    g.V().has('lable,'tank').valueMap('name','display_name','description')
    

    Will return values. I'm not sure why but it gives me a workaround. The bummer is that I have to know the properties of the node before I return them, which is limiting.

    I think this might be more of an Azure issue than a gremlin issue. If you aren't working with Azure CosmosDB, you likely won't have this issue.