locked
How to order data before sending to a UDA function? RRS feed

  • Question

  • I have an azure stream analytics query. It is joining 2 inputs and that needs to be the input of a user defined aggregate function. In the UDA function, I need to do some string concatenation of the incoming rows and output one final string. So the order or the rows from the join is important to be in order of one of the columns which is a string.

    Since order by cannot be used in views, and the format for calling a UDA is through the view, how can I send ordered data to the UDA. The following is my code snippet

    CalcData AS
    (
    SELECT
      x.fqn AS fqn,      
      x.value as xvalue,
      y.value as yvalue,
      x.time as time
    FROM (select fqn
    ,value, time from DataInput1 ) y
    join
    (SELECT
    fqn as fqn,
    value as value,
      time as time
    FROM DataInput2 ) x on y.time=x.time and x.fqn=y.fqn and DATEDIFF(second, x, y) = 0
    --order by time asc, fqn
    ),
    FormatData AS
    (
    SELECT UDA.svgstring(CalcData) AS v,
    time    FROM CalcData
    GROUP BY time,TumblingWindow(minute, 1)
    )

    Any help will be greatly appreciated


    Monday, January 7, 2019 3:11 PM

All replies

  • I tried

    CalcData AS
    (
    SELECT TOP 10000
       x.fqn AS fqn,      
      x.value as xvalue,
      y.value as yvalue,
      x.time as time
    FROM (select fqn
    ,value, time from DataInput1 ) y
    join
    (SELECT
    fqn as fqn,
    value as value,
      time as time
    FROM DataInput2 ) x on y.time=x.time and x.fqn=y.fqn and DATEDIFF(second, x, y) = 0
     order by time, fqn
    ),
    FormatData AS
    (
    SELECT UDA.svgstring(CalcData) AS v,
    time    FROM CalcData
    GROUP BY time,TumblingWindow(minute, 1)
    )

    but it doesn't look like the order by is taking effect

    Monday, January 7, 2019 3:20 PM
  • I see that your question was answered on Stack Overflow
    Wednesday, January 9, 2019 10:57 PM