Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dateTime() function is missing for handling datetime values with a timezone #612

Closed
Tracked by #1438
david-sitsky opened this issue Oct 23, 2022 · 14 comments · Fixed by #1850 or #1866
Closed
Tracked by #1438

dateTime() function is missing for handling datetime values with a timezone #612

david-sitsky opened this issue Oct 23, 2022 · 14 comments · Fixed by #1850 or #1866
Assignees
Labels
customer customer Effort - Unknown Effort - Unknown feature feature Frequency - EveryTime Frequency - EveryTime Reach - Most Reach - Most Severity - S3 Severity - S3
Milestone

Comments

@david-sitsky
Copy link

I wrote about this issue here: https://discourse.memgraph.com/t/support-for-datetime-function-in-cypher/327/2 but it was suggested I report it here.

I have been trying out memgraph and I have Kafka records written in JSON format. I have been able to import the data successfully and have a “transformation” that reads it and runs the Cypher query per Kafka record successfully to create my graph data.

I have JSON properties written in a common “ISO date-time” format, for example:

2003-01-16T06:59:32.000Z

I can see memgraph’s Cypher has a localDateTime() function, but not a dateTime() function like in Neo4J. Is there a reason for this?

@katarinasupe
Copy link
Contributor

Thank you @david-sitsky for opening the issue here 😄

@gitbuda
Copy link
Member

gitbuda commented Nov 17, 2022

@david-sitsky when we designed the feature, all our use cases but also the current ones don't need the timezone part (I think that's the issue here?) + we actually have an optimization on the storage side which is possible because of that. I'm not saying it's not possible to add another data type, but would like to understand the actual need first 😄

Is it possible from your perspective to use the localDateTime() as an alternative to the dateTime()?

Thanks for reporting and let's figure out what's the best here 😄

@gitbuda gitbuda added feature feature and removed bug bug labels Nov 17, 2022
@david-sitsky
Copy link
Author

david-sitsky commented Nov 18, 2022 via email

@Josipmrden
Copy link
Contributor

Can I close this @gitbuda ?

@PrivateGER
Copy link

The thing I'm facing here is that it's impossible to migrate Neo4j data that used DateTime() without an external python convert script.

This issue should really be mentioned in your https://memgraph.com/blog/how-to-migrate-from-neo4j-to-memgraph article.

@katarinasupe
Copy link
Contributor

katarinasupe commented Apr 14, 2023

Hi @PrivateGER, thanks for pointing this out. We will create a migration guide on our documentation to avoid such issues. The blog post talked about one way of migrating your data, and I recommend you join our Discord server, if you haven't, so that we can better help you in the process of migration. Currently, users reported that the best way to migrate their data was to either have their dataset in CSV files and import it with LOAD CSV clause in Memgraph, or by exporting all data from Neo4j in a file that consist of cypher queries (cypherl file), changing it a bit (a bit different syntax for constraints and indexes) and importing it into Memgraph via mgconsole or Memgraph Lab.

Kudos to the community member for sharing these tips:

To migrate, use this command on Neo4j:
call apoc.export.cypher.all("file_name.cypherl", {format:"plain", useOptimizations:{type:"NONE"}, writeNodesProperties: true})

Go into the generated file and change the constraint creation queries, from:
CREATE CONSTRAINT <constraintName> FOR (node:<Label>) REQUIRE (node.<prop>) IS UNIQUE;

to
CREATE CONSTRAINT ON (node:<Label>) ASSERT node.<prop> IS UNIQUE

Since both engines use a different syntax.
After that, import the .cypherl file into Memgraph.

Now, some changes might be required if you have multiple databases or models. But then you should just make some changes in the apoc.export.cypher.all configuration parameters.

The user only had uniqueness constraints. Here are the docs for the existence constraint syntax in Memgraph.
Be careful, and please also create indexes before importing data into Memgraph. If you are using cypherl file, add lines at the beginning with index creation. Here are the tips on when to create indexes.

@Josipmrden
Copy link
Contributor

Josipmrden commented Apr 14, 2023

Hey @PrivateGER, to get to the issue again. Is it the case that Neo4j supports a timezone part in its database types and we don't?

And what does your external script do in order to mitigate the issue?

And additional questions, is it ever the case that in Neo4j you will have additional characters that are in other timezone, other than "Z"?

@katarinasupe
Copy link
Contributor

katarinasupe commented Apr 14, 2023

The issue is there is no temporal type in Memgraph which supports timezone. For example, here are the steps to reproduce the issue if we try creating a relationship with a localDateTime property:

Run query:
CREATE (u:User)-[:CREATED {createdAt: localDateTime("2003-01-16T06:59:32.000")}]->(p:Post)

Here is what you get in Memgraph:

Screenshot 2023-04-14 at 11 41 35

This happens because localDateTime type does not support ending Z which indicates that that time is UTC.

@PrivateGER
Copy link

@katarinasupe got it right.

My script simply parsed the CSV file, took the RFC 3339 timestamps, and converted them. I didn't go with Memgraph for different reasons this time, but may in the future.

@antejavor antejavor added Importance - I2 Importance - I2 Importance - I3 Importance - I3 and removed Importance - I2 Importance - I2 labels Jun 7, 2023
@coryvirok
Copy link

coryvirok commented Jul 11, 2023

I'll add my support for including non-local datetime. Without it, we need to store the datetime as a UNIX timestamp alongside a timezone field. Having Memgraph assume the format is local time is a non-starter especially in a cloud environment where we do not know what the server's local timezone is set to.

Thanks

@katarinasupe
Copy link
Contributor

Hi @coryvirok, thanks for adding your support. As you can see, we added a higher impact to this feature. Did you maybe try some workaround for now? Are you streaming data into the database? I am just trying to figure out how large of a blocker this is for you to prioritize better. Btw. feel free to join our Discord server if you'd like to talk more since the communication should be easier there 😄

@coryvirok
Copy link

I'm still in early phases of deciding between Graph DBs but I ran into this while building a test schema. I can work around it for now, but if I was already using Neo4J this would have been a blocker to using Memgraph as a "drop in replacement" like I see messaged on the website. Thanks for your response.

@katarinasupe katarinasupe added Importance - I1 Importance - I1 and removed Importance - I3 Importance - I3 labels Jul 12, 2023
@Josipmrden
Copy link
Contributor

Josipmrden commented Jul 17, 2023

@antoniofilipovic please read this so we can see what to do, it seems not at all times one is able to know what's the server local timezone
@gitbuda also

@antejavor antejavor added the DX label Oct 18, 2023
@hal-eisen-MG hal-eisen-MG added the Effort - Unknown Effort - Unknown label Oct 25, 2023
@Josipmrden Josipmrden added the Severity - S3 Severity - S3 label Oct 25, 2023
@as51340 as51340 assigned as51340 and unassigned gitbuda and as51340 Oct 27, 2023
@as51340 as51340 changed the title [BUG] dateTime() function is missing for handling datetime values with a timezone dateTime() function is missing for handling datetime values with a timezone Oct 27, 2023
@gitbuda gitbuda added the customer customer label Nov 2, 2023
@hal-eisen-MG hal-eisen-MG removed the DX label Nov 28, 2023
@matea16
Copy link

matea16 commented Jan 23, 2024

+1 from the community

@hal-eisen-MG hal-eisen-MG added Priority - Later Priority - Later and removed Priority - Later Priority - Later labels Feb 4, 2024
@katarinasupe katarinasupe added Frequency - EveryTime Frequency - EveryTime Reach - Most Reach - Most and removed Importance - I1 Importance - I1 labels Feb 27, 2024
@antepusic antepusic linked a pull request Mar 25, 2024 that will close this issue
7 tasks
@antepusic antepusic modified the milestones: mg-v2.16.0, mg-v2.17.0 Mar 25, 2024
@antepusic antepusic linked a pull request Mar 28, 2024 that will close this issue
9 tasks
@antepusic antepusic reopened this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer customer Effort - Unknown Effort - Unknown feature feature Frequency - EveryTime Frequency - EveryTime Reach - Most Reach - Most Severity - S3 Severity - S3
Projects
None yet