Skip to content

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

@cago-rebl

Description

@cago-rebl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions