USQL - SQL.ARRAY 获取长度?
USQL - SQL.ARRAY get length?
对于上下文,我从传感器获取数据并将其存储在这样的字符串中
"axes" : "...,1,23,21,0,12,10,212,12,..."
大小可能会根据发送数据的机器而改变...所以我的目标是像 SQL.ARRAY 一样存储它,我想稍后获取此数组的大小以执行一些业务报告。
有没有办法找到 SQL.ARRAY 的长度?
@outputfile =
SELECT m.MachineID,
COUNT( * ) AS nbAxesArray
FROM MachineInfos AS m
JOIN
LoadDataAxes AS lda
ON m.EventIoTID == lda.EventIoTID
//WHERE getLength(lda.L) == 0 // something like this
GROUP BY m.MachineID;
SQL.ARRAY
复杂类型有许多方法,例如 Count
并在底层实现了 IEnumerable*。
一个简单的例子:
DECLARE @outputFile string = @"output/output.csv";
@input =
SELECT *
FROM ( VALUES
( 100, "1,23,21,0,12,10,212,12" ),
( 101, "7,8,9" )
) AS x(rowId, y);
// Convert the string to array
@working =
SELECT rowId, new SQL.ARRAY<string>(y.Split(',')) AS z
FROM @input;
/*
// Explode the array to individual rows
@output =
SELECT b
FROM @working
CROSS APPLY
EXPLODE(z) AS a(b);
*/
@output =
SELECT rowId, z.Count AS c
FROM @working;
OUTPUT @output
TO @outputFile
USING Outputters.Csv(quoting:false);
*(我认为)
我的结果:
其他一些例子here。有帮助吗?
对于上下文,我从传感器获取数据并将其存储在这样的字符串中
"axes" : "...,1,23,21,0,12,10,212,12,..."
大小可能会根据发送数据的机器而改变...所以我的目标是像 SQL.ARRAY 一样存储它,我想稍后获取此数组的大小以执行一些业务报告。
有没有办法找到 SQL.ARRAY 的长度?
@outputfile =
SELECT m.MachineID,
COUNT( * ) AS nbAxesArray
FROM MachineInfos AS m
JOIN
LoadDataAxes AS lda
ON m.EventIoTID == lda.EventIoTID
//WHERE getLength(lda.L) == 0 // something like this
GROUP BY m.MachineID;
SQL.ARRAY
复杂类型有许多方法,例如 Count
并在底层实现了 IEnumerable*。
一个简单的例子:
DECLARE @outputFile string = @"output/output.csv";
@input =
SELECT *
FROM ( VALUES
( 100, "1,23,21,0,12,10,212,12" ),
( 101, "7,8,9" )
) AS x(rowId, y);
// Convert the string to array
@working =
SELECT rowId, new SQL.ARRAY<string>(y.Split(',')) AS z
FROM @input;
/*
// Explode the array to individual rows
@output =
SELECT b
FROM @working
CROSS APPLY
EXPLODE(z) AS a(b);
*/
@output =
SELECT rowId, z.Count AS c
FROM @working;
OUTPUT @output
TO @outputFile
USING Outputters.Csv(quoting:false);
*(我认为)
我的结果:
其他一些例子here。有帮助吗?