[
https://issues.apache.org/jira/browse/NIFI-9357?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Pierre Villard resolved NIFI-9357.
----------------------------------
Resolution: Feedback Received
Apache NiFi 1.x is no longer maintained and no new release is planned on the
1.x release line. Marking as resolved as part of a cleanup operation. Please
open a new one with an updated description if this is still relevant for NiFi
2.x.
> DataTypeUtils: Wrong conversion of String to Double in case of choice in
> schema
> -------------------------------------------------------------------------------
>
> Key: NIFI-9357
> URL: https://issues.apache.org/jira/browse/NIFI-9357
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.13.2
> Environment: Linux & Windows
> Reporter: André Lison
> Priority: Major
>
> Hello,
> given a message schema that defines a field being either string, double or
> null:
> {
> ...
> "fields": [
> { "name": "Value", "type": [ "null", "double", "string"] }
> ]
> }
> This schema is used by a JSONTreeReader to parse following message:
> {{[{}}
> {{"Value": "12345"}}
> {{}]}}
> Unfortunately the DateTypeUtils detects that the string contains a number and
> converts it to a double. This behaviour is undesired. In my case this leads
> to the situation, that a double is written to an influx field. However, in
> the next message the Value field could hold a string which is not parsable to
> a number and thus the data type stays unchanged "string". Trying to write a
> string to a shard which is already prepopulated with a double results in an
> error.
> The desired behaviour is, to preserve the string when the schema allowes a
> string. Likewise for other datatypes.
> I tracked it down to the
> org.apache.nifi.serialization.record.util.DataTypeUtils#findMostSuitableTypeByStringValue
> method.
> This method sorts the possible data types from the schema by theirs enum type
> and returns the first match. In my above case this is always double.
> Best,
> André
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)