TLDR: In a Stream Analytics Job, I can’t seem to CAST stringified integer to float.
Long version: So I have a Stream Analytics Job, fetching messages from an Azure IoT Hub, formatting and outputting to Postgres. Good? Good! In Postgres, I have a column of type float, where sometimes I insert values with decimals, e.g. 4.3 or 1.5 and sometimes values without decimals (aka integers), e.g. 2 or 4. Good? Good!
What seems to be the officer, problem?
The problem is that while converting values from JSON, the Stream Analytics Job, seems to ignore my cast-action. I explicitly ask to convert ‘0’ to a nice float 0.0 but I always get a bigint instead. This of course causes the data-insertion to break in Postgres.
THIS HAS TO BE A BUG, RIGHT?
I asked for help on Tw… X, and I did get help but we couldn’t find a solution.
@AzureStreaming "cast as float" does not seem to work for postgres-output when the value does not contain decimals e.g. { value: "0" } gets a bigint value instead of float. Writing "0.0" didn't help either. Image for reference. Any workaround for this? pic.twitter.com/DyfbPAufkI
— Nikos Delis (@ndteknik) August 23, 2023
Microsoft Learn didn’t help either. Pfff…
I don’t have the solution yet, but I promise to update this post once I find one.
UPDATE: I found one! Read here!