Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

NiFi Avro Schema for UUID to insert to Cassandra

avatar
Explorer

Hello,

I am using the below Avro schema to insert records to cassandra using PutCassandraRecord processor, here this column is uuid datatype in cassandra database but nifi is not able to resolve this datatype and the getting this error

PutCassandraRecord[id=676539f3-2fc7-173e-8d3f-2e703922f111] Unable to write the records into Cassandra table due to com.datastax.driver.core.exceptions.InvalidQueryException: UUID should be 16 or 0 bytes (36)
- Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: UUID should be 16 or 0 bytes (36): {}

 

Avro Schema defined in AvroSchemaRegistry

 

 

 

 

{
    "type": "record",
    "name": "provenance_event",
    "namespace": "provenanceRecords",
    "fields": [{
        "name": "id",
	  	"type": ["null", {"type": "string", "logicalType": "uuid"}],
        "default": null
    }]
}

 

 

 

 

NiFI avro schema is not able to convert string datatype to uuid

 

Sample JSON which I sending

[ { "id" : "5b616957-2a98-4a9e-97c8-2d2333966a0f" }]

 

I am on NiFi 1.16.3 version

@MattWho@Bryan Bende

2 REPLIES 2

avatar

@Meeran Going out on a limb, but i think the conflict is related to "LogicalType" of uuid not preparing the downstream value to what casssandra expects.  The error seems to think the logicalType of the string is the wrong format.  I think the error on the cassandra driver level, not with the schema or nifi itself.     

 

One suggestion i have is that you could just make that a string (without the type) and see if the driver accepts.   If it does, then you know the issue is just related to the LogicalType logic.  As long as your uuid is not manipulated you do not need to re-confirm its actually a uuid in the nifi data flow.

avatar
Explorer

yeah. I tried that but still same issue