So I'm trying to run the following query in stream analytics:
WITH
InputData AS(
SELECT
tags.[tag0] AS 'shift',
tags.[tag1] AS 'Good Count',
tags.[tag2] AS 'Bad Count'
FROM
[Kepware]
),
Transform1 AS(
SELECT
shift,
CASE
WHEN [Good Count] - (LAG([Good Count], 1, [Good Count]) OVER (LIMIT DURATION(day, 1))) < 0 THEN [Good Count] + 1
ELSE [Good Count] - (LAG([Good Count], 1, [Good Count]) OVER (LIMIT DURATION(day, 1)))
END AS [Good Diff],
CASE
WHEN [Bad Count] - (LAG([Bad Count], 1, [Bad Count]) OVER (LIMIT DURATION(day, 1))) < 0 THEN [Bad Count] + 1
ELSE [Bad Count] - (LAG([Bad Count], 1, [Bad Count]) OVER (LIMIT DURATION(day, 1)))
END AS [Bad Diff]
FROM
[InputData]
)
SELECT
SUM([Good Diff]) AS [Shift Good Count]
INTO
[LiveTableTest]
FROM
[Transform1]
WHERE
shift = 1
GROUP BY
SlidingWindow(hour,8)
When I run the test query it shows the correct result in the test results tab. The SQL table schema (preview) tab shows that the result is a bigint just like the table column, yet I get this error and nothing gets written to the table.
"[SQL Server Azure instance 'mysqlserverxxxxx.database.windows.net', table [Database].[Live Table Test]] Cannot write 4 events to SQL Database output at LiveTableTest. Detailed Error: - Conversion of property 'Shift Good Count' of type 'System.Double' to table column 'Shift Good Count' of type 'System.Int64' is not supported.\r\n"
When I go into the database I can see the column I'm trying to fill is a bigint so I'm not sure what is happening here. Any help is appreciated.
Edit: I changed the SQL column to float and now the output is as expected but I'm not sure why the change to double/float occurs when the output still looks like an integer.