[
https://issues.apache.org/jira/browse/NIFI-15474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18055578#comment-18055578
]
ASF subversion and git services commented on NIFI-15474:
--------------------------------------------------------
Commit d9f9147306f5b6d999fb6cabbfb9b62a2ef722ae in nifi's branch
refs/heads/main from Robert Jensen
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=d9f9147306 ]
NIFI-15474 Support timestamp truncation in RecordPath DSL
This closes #10796.
Signed-off-by: Pierre Villard <[email protected]>
> 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: 1h
> 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)