Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-13-2021 01:03 PM
Is there a way to take a URN like urn:epc:id:sscc:0614141.1234567890 and convert this to a deterministic UUID that produces the same UUID every time I convert it.
I have a client where this would be a really extremely helpful feature as they are trying to figure out all the ways their disparate data systems connect. And could always default into proper generated UUID at a later date.
Just as sample code - here is something I coded up in PySpark to do something in a different arena. I wonder if like this function - seeding a function would be key.
def deterministic_uuid(seed:str):
m = hashlib.md5()
m.update(seed.encode('utf-8'))
new_uuid = uuid.UUID(m.hexdigest())
return str(new_uuid)
# line below makes this function available in PySpark/Spark
uuid_udf = F.udf(lambda x: deterministic_uuid(x), StringType())
Thanks,
Matt
05-15-2021 01:47 PM
Hello @mjlefevre and welcome to the Neo4j community
Right now, there are two options for UUID in Neo4j but you cannot seed the function:
Otherwise you can gereate the MD5 based on some properties.
Finally you can also generate the UUID in python before to load the data into the database.
Regards,
Cobra
All the sessions of the conference are now available online