Feb 11 2019
05:35 AM
- last edited on
Apr 07 2022
05:38 PM
by
TechCommunityAP
Feb 11 2019
05:35 AM
- last edited on
Apr 07 2022
05:38 PM
by
TechCommunityAP
I have written a query that is a bit involved, it is multi-line and it contains a union and a call to lookup. It works well as a query, but if I save it as a function and then try to run that, I get an error:
" 'lookup' operator: Failed to resolve table or column expression named 'domain_specific' "
Is this a known limitation or is this just a matter of parsing and I can add parenthesis somewhere or something similar ?
Feb 12 2019 10:28 PM
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.
Feb 13 2019 03:08 AM - edited Feb 13 2019 03:12 AM
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 04:24 AM
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.
Feb 13 2019 05:28 AM
Feb 13 2019 05:33 AM
Hi,
I am not sure if I understand this:
The 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.
In my case if you use the workspace() operator in query that works. That is expected behavior as that is the intention of the operator. When you save a query that has workspace() operator in it as function and you try to call the saved function you will get error. At least I got error. This means that using workspace() operator in a function is not supported. Have you tried saving the exact query you have but without using workspace() operator and than calling that function?
Feb 13 2019 06:53 AM
I meant I have successfully created a function that uses a different workspace and works correctly, both as a query and as a custom function, this one in particular :
Feb 13 2019 07:27 AM
SolutionIf 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.
Mar 03 2019 12:11 AM
I have opened a support case for this behavior, and the Kusto team acknowledged this is a bug. I was told it should be fixed around the 6th of March.
Feb 13 2019 07:27 AM
SolutionIf 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.