Azure / Azure/azure-stream-analytics

Conversion error in Stream Analytics Job when processing JSON data has a "double" property

Open
#177 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
229
Forks
920
PR merge metrics
No merged PRs in 30d

Description

Hello,

I have a console application that streams JSON data to an Azure IoT hub with the following format:
```
{
"Name": "testname",
"testvalue": 0,
}
```
This JSON represents a C# model in my console app, which looks like this:
```
public class testmodel
{
public double Name { get; set; }
public double testvalue { get; set; }
}
```

After the data has been sent up to the hub, my stream analytics job processes it and outputs it to my PostgreSQL database in the testtable table, which has the following columns:

- name (varchar)
- testvalue (float4)

The query I'm using for this is:
```
SELECT
Input.Name AS name
,CAST(Input.testvalue AS float) AS testvalue
INTO
[test-db]
FROM
[iothub] AS Input TIMESTAMP BY Input.EventProcessedUtcTime
```

However, when the analytics job tries to insert the data, I encounter errors indicating that the conversion from bigint to float is failing.

The problem here is that the "testvalue" field sometimes includes decimals and sometimes does not. This inconsistency is causing the issue: when the "testvalue" field contains decimals, the conversion works correctly, but when it does not contain decimals, the conversion fails.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.