1
votes

I have some graph data with date type values. My gremlin query for the date type property is working, but output value is not the date value.

Environment:

  • Janusgraph 0.3.1
  • gremlinpython 3.4.3

Below is my example:

  • Data (JanusGraph): {"ID": "doc_1", "MY_DATE": [Tue Jan 10 00:00:00 KST 1079]}
  • Query: g.V().has("ID", "doc_1").valueMap("MY_DATE")
  • Output (gremlinpython): datetime(1079, 1, 16)

The error is 6 days (1079.1.10 -> 1079.1.16). This mismatch does not occur when the years are above 1600. Does the timestamp have some serialization/deserialization problems between janusgraph and gremlinpython?

Thanks

2

2 Answers

1
votes

There were some issue with Python and dates but I would have them fixed for 3.4.3, which is the version you stated you were using. The issue is described here at TINKERPOP-2264 along with the fix, but basically there were some issues with timezones. From your example data, it looks like you store your date with a timezone (i.e. KST). I'm not completely sure, but I would imagine things would work as expected if the date was stored as UTC.

1
votes

After some try & search, I found that there are some difference between java Date and python datetime. (Julian vs. Gregorian Calendar) So I have replaced SimpleDateFormat with JodaTime and got the expected result as below:

  • Data (Raw): {"ID": "doc_1", "MY_DATE": "1079-1-29"}
  • Data (JanusGraph): {"ID": "doc_1", "MY_DATE": [Wed Jan 23 00:32:08 KST 1079]}
    • (I think the JanusGraph uses java Date object internally..)
  • Query: g.V().has("ID", "doc_1").valueMap("MY_DATE")
  • Output (gremlinpython): datetime(1079, 1, 29)

Thanks