[
https://issues.apache.org/jira/browse/NIFI-15474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rob Jensen updated NIFI-15474:
------------------------------
Status: Patch Available (was: Open)
https://github.com/apache/nifi/pull/10796
> Support timestamp truncation in RecordPath DSL
> ----------------------------------------------
>
> Key: NIFI-15474
> URL: https://issues.apache.org/jira/browse/NIFI-15474
> Project: Apache NiFi
> Issue Type: New Feature
> Reporter: Rob Jensen
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> I'd like to have the ability to truncate a unix timestamp in NiFi with the
> RecordPath DSL - for example, if I have a number with value {{1768430253}}
> I'd like to be able to truncate it to, say, the nearest minute
> {{{}1768430220{}}}, or any other interval. This operation should support any
> unix timestamp format (seconds, millis, micros or nanos). It should accept a
> string or number and return a number.
> I propose implementing this by adding a small family of functions that can be
> composed by the user to implement the truncation logic:
> * `multiply(n, m)` - returns the product n * m
> * `divide(n, m)` - return the quotient n / m
> * `toNumber(v)` - return the result of casting v to number
> These functions should behave like their equivalents in the expression
> language
> For a sample use case, consider a `PartitionRecord` processor that receives
> flowfiles with a long `timestamp` field in unix seconds format. I want to be
> able to emit one flowfile per five minute bucket with the following
> RecordPath expression:
> {code:java}
> multiply( toNumber( divide( /timestamp, 300 ) ), 300 ){code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)