Azure 流分析 - 加入 csv 文件返回 0 行
Posted
技术标签:
【中文标题】Azure 流分析 - 加入 csv 文件返回 0 行【英文标题】:Azure stream analytics - Joining on a csv file returns 0 rows 【发布时间】:2015-06-29 16:26:34 【问题描述】:我有以下疑问:
SELECT
[VanList].deviceId
,[VanList].[VanName]
events.[timestamp]
,events.externaltemp
,events.internaltemp
,events.humidity
,events.latitude
,events.longitude
INTO
[iot-powerBI]
FROM
[iot-EventHub] as events timestamp by [timestamp]
join [VanList] on events.DeviceId = [VanList].deviceId
其中 iot-eventHub 是我的事件中心,VanList 是已上传到 Azure 存储的参考列表(csv 文件)。
我已经尝试上传示例数据来测试查询,但它总是返回 0 行。
以下是我的事件中心输入捕获的 JSON 示例
[
"DeviceId":1,
"Timestamp":"2015-06-29T12:15:18.0000000",
"ExternalTemp":9,
"InternalTemp":8,
"Humidity":43,
"Latitude":51.3854942,
"Longitude":-1.12774682,
"EventProcessedUtcTime":"2015-06-29T12:25:46.0932317Z",
"PartitionId":1,
"EventEnqueuedUtcTime":"2015-06-29T12:15:18.5990000Z"
]
以下是我的 CSV 参考数据示例。
deviceId,VanName
1,VAN 1
2,VAN 2
3,Standby Van
两个列表都包含 1 的设备 ID,因此我希望我的查询能够将两者结合在一起。
我尝试在查询语法中同时使用“内连接”和“连接”,但都没有成功连接。 我的流分析查询出了什么问题?
【问题讨论】:
【参考方案1】:尝试在连接中添加 CAST 函数。我不确定为什么会这样,并且为 VanList 参考数据输入添加 CREATE TABLE 子句并不能完成同样的事情。但我认为这行得通。
SELECT
[VanList].deviceId
,[VanList].[VanName]
,events.[timestamp]
,events.externaltemp
,events.internaltemp
,events.humidity
,events.latitude
,events.longitude
INTO
[iot-powerBI]
FROM
[iot-EventHub] as events timestamp by [Timestamp]
join [VanList] on events.DeviceId = cast([VanList].deviceId as bigint)
【讨论】:
【参考方案2】:我唯一能看到的是您在原始查询中缺少逗号,否则它看起来是正确的。我会尝试重新创建流分析作业。这是另一个对我有用的例子。
SELECT
countryref.CountryName as Geography,
input.GeographyId as GeographyId
into [country-out]
FROM input timestamp by [TransactionDateTime]
Join countryref
on countryref.GeographyID = input.GeographyId here
输入数据示例
"pageid":801,"firstname":"Gertrude","geographyid":2,"itemid":2,"itemprice":79.0,"transactiondatetime":"2015-06-30T14:25:51.0000000","creditcardnumber":"2ggnC"
"pageid":801,"firstname":"Venice","geographyid":1,"itemid":10,"itemprice":169.0,"transactiondatetime":"2015-06-30T14:25:51.0000000","creditcardnumber":"xLyOp"
"pageid":801,"firstname":"Christinia","geographyid":2,"itemid":2,"itemprice":79.0,"transactiondatetime":"2015-06-30T14:25:51.0000000","creditcardnumber":"VuycQ"
"pageid":801,"firstname":"Dorethea","geographyid":4,"itemid":2,"itemprice":79.0,"transactiondatetime":"2015-06-30T14:25:51.0000000","creditcardnumber":"tgvQP"
"pageid":801,"firstname":"Dwain","geographyid":4,"itemid":4,"itemprice":129.0,"transactiondatetime":"2015-06-30T14:25:51.0000000","creditcardnumber":"O5TwV"
国家参考数据
[
"GeographyID":1,
"CountryName":"USA"
,
"GeographyID":2,
"CountryName":"China"
,
"GeographyID":3,
"CountryName":"Brazil"
,
"GeographyID":4,
"CountryName":"Andrews country"
,
"GeographyID":5,
"CountryName":"Chile"
]
【讨论】:
以上是关于Azure 流分析 - 加入 csv 文件返回 0 行的主要内容,如果未能解决你的问题,请参考以下文章