Search code examples
apache-nifi

Fill in a partiiton field with current date in PartitonRecord processor in Apache NiFi


I need to partition records comes from Kafka based on date. For this purposes I use PartitionRecord processor with a dynamic property partition_date (every message has a property created_at). But some messages don't have created_at field (delete events). So I need somehow to fill in partition_date attribute if created_at is Null. I suppose I can use nifi expression language for it - if created_at is null then use {now()} else take date form message. Could you suggest me how to create such expression?


Solution

  • Use a UpdateAttribute processor:

    • partition_date (dynamic property): ${created_at:isNull():ifElse(${now()}, ${created_at})}