[
https://issues.apache.org/jira/browse/TINKERPOP-2057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
stephen mallette closed TINKERPOP-2057.
---------------------------------------
Resolution: Not A Problem
sorry - took me a while to get to digging into this. upon investigation, i
don't think that there's a problem here with Gremlin. It's an issue with the
way dictionaries work native to Python. So here's your output:
{code}
gremlin> g.V().as("a").out().out().as("b").path().group().by(__.select("a",
"b")).unfold()
==>{a=v[1], b=v[3]}=[[v[1], v[4], v[3]]]
==>{a=v[1], b=v[5]}=[[v[1], v[4], v[5]]]
{code}
You're returning a dictionary that uses a dictionary as a key. Python
dictionary is immutable and therefore doesn't work as a key:
https://stackoverflow.com/q/20115680/1831717
It seems the dict could be "frozen" according to that answer, but I don't think
we will do that. I think that this is just a limitation of the Gremlin language
in python and that you should just alter your result structure to return a key
that works for dictionaries in python.
Since this is behavior is expected of Python, I'm going to close this as it's
not a bug - if you'd like to discuss it further, please bring up your concerns
on the dev list.
https://lists.apache.org/[email protected]
> TypeError when grouping by multiple attributes
> ----------------------------------------------
>
> Key: TINKERPOP-2057
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2057
> Project: TinkerPop
> Issue Type: Bug
> Components: python
> Affects Versions: 3.3.3
> Reporter: Pierce Freeman
> Priority: Major
>
> The python serialization engine fails when trying to group a path by two
> intermediate variables:
>
> {code:java}
> graph = Graph()
> g =
> graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
> g.V().as_("a").out().out().as_("b").path().group().by(__.select("a",
> "b")).unfold().toList()
> {code}
> {code:java}
> ~/tinkerpop/gremlin-python/src/main/jython/gremlin_python/structure/io/graphsonV3d0.py
> in objectify(cls, l, reader)
> 456 while x < len(l):
> 457 new_dict[reader.toObject(l[x])] = reader.toObject(l[x + 1])
> --> 458 x = x + 2
> 459 return new_dict
> 460
> TypeError: unhashable type: 'dict'
> {code}
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)