查询从字符串强制转换为浮动到sql表失败 [英] Query with cast from string to float into sql table failing

查看:102
本文介绍了查询从字符串强制转换为浮动到sql表失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个流分析查询,在控制台中进行测试时可以正常运行,但是在运行流分析作业时失败.它需要一个JSON数组输入,其值的格式设置为字符串.在执行以下操作之前,查询必须将此字符串强制转换为浮点型 当天的AVG.这似乎失败了.  来自IoT中心的输入 是:

I have a stream analytics query that works fine when tested in the console, but fails when I run the stream analytics job.  It takes a JSON array input with a value formatted as string.  The query must cast this string to a float before doing the AVG for the day.  This seems to fail.   Input from IoT hub  is:

查询是:

Average1dayGw2 AS
Average1dayGw2 AS

推荐答案

我不认为这是问题所在.我使用下面的查询,并得到如下图所示的结果

 I dont think that is the issue. I used the below query and got the result as in the image below

SELECT arrayElement.ArrayValue.device AS gatewayid, arrayElement.ArrayValue.ch AS channelid, arrayElement.ArrayValue.name AS name, arrayElement.ArrayValue.eu AS eu, 'avg1day' AS calculation,

'Ok'AS状态,AVG(TRY_CAST(arrayElement.ArrayValue.value AS float))作为值 INTO [sqldb-out-runtime] 从[gwiothub2-in]作为事件 交叉应用GetArrayElements(event.data)AS arrayElement GROUP BY arrayElement.ArrayValue.device,arrayElement.ArrayValue.ch,arrayElement.ArrayValue.name,

'Ok' AS status,AVG(TRY_CAST(arrayElement.ArrayValue.value AS float)) as value INTO [sqldb-out-runtime] FROM [gwiothub2-in] as event CROSS APPLY GetArrayElements(event.data) AS arrayElement GROUP BY arrayElement.ArrayValue.device, arrayElement.ArrayValue.ch, arrayElement.ArrayValue.name,

arrayElement.ArrayValue.eu,TUMBLINGWINDOW(day,1)

arrayElement.ArrayValue.eu, TUMBLINGWINDOW(day, 1)




我不了解您的时间戳记.我认为这导致了错误.请看一下查询的那一部分.

I didn't understand your timestamp by statement. I think that is causing an error. Please take a look at that part of the query.


这篇关于查询从字符串强制转换为浮动到sql表失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆