Forum Discussion
Can any query be saved as a function ?
- Feb 13, 2019
If you think this is some kind of a bug better log official case to MSFT. Seems the combination of using let with workspace() operator is causing the error. I for sure haven't seen this behavior documented.
Hi,
Can you provide the query or may be some example to understand what kind of operators are you using there? Keep in mind that in function you cannot use another function.
- DeletedFeb 13, 2019
You mean my function can't use substring or extract for example ?
I have tested that, and it works. I guess you mean other custom functions, I haven't done that.
This is a shorter version of my query that also gets the same error ( with names changed ) :
let short = workspace("something").Event_CL | distinct TenantId_s | extend stn=substring(TenantId_s, 1, 5);
let Parsed_logs = Whatever_CL | parse RawData with * "[[[[" x1 "] [" x2 "] [] [" x3 "] [203] [] [] [] [string] [" x4 "] [] [1] [] [203] [" x5 " line:" x6 "]" x7 | project x1,x2,x3,x4,x5,x6, compId;
Parsed_logs | extend stn = extract("(yyy)(\\d{5}).*",2, compId ) | lookup kind=leftouter short on stn | project-away stn- Feb 13, 2019
Hi,
Yes by function I mean another custom function. Things like count(), summarize, extend are operators in the query language. I hope that makes it a little bit easier. I thing the problem comes that you are referring to another workspace in the function. As far as I understand you cannot use workspace() operator in functions. I do not think that is documented. It would be good if it is. Try to use the same query but without referencing another workspace. If it works than that is the problem.
- DeletedFeb 13, 2019The workspace command alone works in the scope of a function, I have tried all the variations. In this case the error is informative, it is only lookup that fails when run from inside a function.