1
votes

I am trying to send the output from table recordtime value to Function1 as a parameter value. but i am getting below error for Function1()

semantic error: SEM0100: 'toscalar' operator: Failed to resolve scalar expression named 'recordtime'.

I tried with recordtime as passing as tostring() and todatetime()

Function definitions:
Function1(fromdate string,recordtime string)
Function2(fromdate string,enddatetime string)
Main (startdate,enddatetime,id)

Function Main (startdate,enddatetime,id){
    TestTable 
    | where (fromdate >= datetime(startdate)
    and todate <= datetime(enddatetime))
    and deviceid == id
    | summarize cnt = count(), recordtime = Timestamp
    | extend getdates = case (
                              cnt == 1,toscalar(Function1(startdate,recordtime)),
                              cnt == 2,toscalar(Function2(startdate,enddatetime )),
                             "Out of range"
                             )
    | Project getdates 
}
Function1 and Function2 returns single array like ([{"fromdate":"2020-03-11T16:39:47.6730000Z"},{"todate":"2020-03-11T16:44:23.8800000Z"}]

any suggestions, Thanks in advance

1

1 Answers

1
votes

Function1 is a tabular function and therefore can't be called in the middle of a query in that way.

If Function1 "functionally returns a scalar", then move the toscalar() inside the Function1, so you can remove toscalar when you call it and you can call that function on a query column.