Hi Team
I have a date datefield storing current datetime in it want to create a UUID using same column how i can create . currently using groovy script to create UUID but want to use same column and create it
Best answer by Bikram
View originalHi Team
I have a date datefield storing current datetime in it want to create a UUID using same column how i can create . currently using groovy script to create UUID but want to use same column and create it
Best answer by Bikram
View original
kindly try this.
String timeuuid = com.datastax.driver.core.utils.UUIDs.timeBased().toString();
@bikram
thanks for the response as always
but before this am creating a dateinhour column to store current date and i want to use that column to generate UUID is that possible to pass that in parameter for above function ?
I tried this in jython , kindly try it in your pipeline and let me know if it helps.
from datetime import datetime
from uuid import uuid4
date_time = datetime.now().strftime('%Y%m-%d%H-%M%S')
eventid = date_time + str(uuid4())
for record in sdc.records:
try:
record.value['data'] = eventid
# Write record to processor output
sdc.output.write(record)
except Exception as e:
# Send record to error
sdc.error.write(record, str(e))
Thanks possible to share solution using groovy stage? we are using same and other transformation also
MessageDigest mac = MessageDigest.getInstance("SHA-256");
byte[] signatureBytes = mac.digest(dateInHour.getBytes(StandardCharsets.UTF_8));
StringBuffer hexString = new StringBuffer();
for (int j=0; j<signatureBytes.length; j++) {
String hex=Integer.toHexString(0xff & signatureBytes[j]);
if(hex.length()==1) hexString.append('0');
hexString.append(hex);
}
String encryptedSignature = hexString.toString();
String encryptHash = encryptedSignature.replace("-","");
encryptHash = encryptHash.toUpperCase();
record.value['encryptHash']
output.write(record)
using ths but not able to get the output getting error
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.