[ 
https://issues.apache.org/jira/browse/NIFI-15599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pierre Villard reassigned NIFI-15599:
-------------------------------------

    Assignee: Pierre Villard

> QueryRecord CAST String with miliseconds to TIMESTAMP not always works as 
> expected 
> -----------------------------------------------------------------------------------
>
>                 Key: NIFI-15599
>                 URL: https://issues.apache.org/jira/browse/NIFI-15599
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 2.7.2
>            Reporter: Beat Fuellemann
>            Assignee: Pierre Villard
>            Priority: Major
>         Attachments: Bildschirmfoto 2026-02-13 um 07.55.46.png, 
> Bildschirmfoto 2026-02-13 um 07.56.05.png
>
>
> With queryRecord I need to cast a String with miliseconds format (2026-01-01 
> 12:12:00.123) to a timestamp.
> Unfortunately, that doesn't work in each case.
> ------------------------------------
> Case1: (String directly to timestamp)
> CAST('2026-01-01 12:12:00.123' AS TIMESTAMP) AS ts_from_string_timestamp
> Results:  "ts_from_string_timestamp" : "2026-01-01T12:12:00Z"  -> 
> *MILISECONDS are dropped*
> ------------------------------------
> Case2: (String from content to timestamp)
> CAST(ts_json AS TIMESTAMP) AS ts_from_json_timestamp,
> Result:   "ts_from_json_timestamp" : "2026-03-03T03:23:55.{*}456{*}Z" -> 
> MILISECONDS are shown as expected
> ------------------------------------
> Case3: (String from attribute to timestamp)
> CAST('${ts_attr}' AS TIMESTAMP) AS ts_from_attr_timestamp
> Result: "ts_from_attr_timestamp" : "2026-02-02T20:20:20Z"  -> *MILISECONDS 
> are dropped*
>  
> QueryRecord SQL:
> {code:java}
> select 
> CAST('2026-01-01 12:12:00.123' AS TIMESTAMP) AS ts_from_string_timestamp,
> CAST(ts_json AS TIMESTAMP) AS ts_from_json_timestamp,
> CAST('${ts_attr}' AS TIMESTAMP) AS ts_from_attr_timestamp
> from flowfile {code}
> Result Flowfile original as avro:
> {code:java}
> Objavro.schema�{"type":"record","name":"nifiRecord","namespace":"org.apache.nifi","fields":[{"name":"ts_from_string_timestamp","type":{"type":"long","logicalType":"timestamp-millis"}},{"name":"ts_from_json_timestamp","type":[{"type":"long","logicalType":"timestamp-millis"},"null"]},{"name":"ts_from_attr_timestamp","type":{"type":"long","logicalType":"timestamp-millis"}}]}avro.codecnull{code}
> Result Flowfile  formated as avro:
> {code:java}
> [ {
>   "ts_from_string_timestamp" : "2026-01-01T12:12:00Z",
>   "ts_from_json_timestamp" : "2026-03-03T03:23:55.456Z",
>   "ts_from_attr_timestamp" : "2026-02-02T20:20:20Z"
> } ]{code}
> Because it works in case where the string is get from json content, I think 
> it is a bug in nifi and NOT a limitation of calcite SQL.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to