Created
March 19, 2021 17:51
-
-
Save davidlzs/0435e74c970b3634388c84514d989690 to your computer and use it in GitHub Desktop.
Cassandra UDF textToTimestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE FUNCTION akka_projection.textToTimestamp ( | |
| input TEXT | |
| ) | |
| CALLED ON NULL INPUT | |
| RETURNS Timestamp | |
| LANGUAGE java AS | |
| $$ | |
| final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L; | |
| UUID uuid = UUID.fromString(input); | |
| long time = (uuid.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) / 10000; | |
| Date date = new Date(time); | |
| return date; | |
| $$ | |
| ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment