Why do I get error for cross querying in Kusto

Heidi Zhang 0 Reputation points Microsoft Employee
2024-05-13T19:29:40.3966667+00:00

I can run my function successfully in local cluster but get errors while running in other clusters:

Errors occurred while resolving remote entities. Cluster='https://dummy.kusto.windows.net/', Database='DummyDB': Semantic error: Schema of the stored function 'AllMgmtSmsAccountTrace' expected to be constant and not to depend on input arguments or data. Error details: SEM0001: evaluate execute_query(): the following error(s) occurred while evaluating the output schema: evaluate execute_query() is not allowed in this context.

Example of my query

cluster('dummy.kusto.windows.net').database('DummyDB').AllMgmtSmsAccountTrace

| take 10

Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
490 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sander van de Velde 29,856 Reputation points MVP
    2024-05-13T19:48:07.8833333+00:00

    Hello @Heidi Zhang ,

    welcome to this moderated Azure community forum.

    I tried to replicate your example:

    cluster('https://kvcb9e932a678234837be0.northeurope.kusto.windows.net').database('freeclustervandeveldeonline').MyFunction1()
    | take 5
    

    I was based on an existing stored function:

    User's image

    Notice I added round brackets '()' at the end, after the function name.

    This gives a correct result:

    User's image

    Can you add the round brackets and check your query again?


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


  2. PRADEEPCHEEKATLA-MSFT 80,491 Reputation points Microsoft Employee
    2024-05-20T05:36:08.2133333+00:00

    @Heidi Zhang - Thanks for the question and using MS Q&A platform.

    It seems like you are trying to execute a cross-cluster query in Kusto. The error message you received indicates that the schema of the stored function 'AllMgmtSmsAccountTrace' is expected to be constant and not to depend on input arguments or data.

    This error can occur when you use the evaluate operator in a stored function that is called from a remote cluster. The evaluate operator is not allowed in this context because it can produce a schema that depends on the input data.

    To resolve this issue, you can modify your query to avoid using the evaluate operator in the stored function. Instead, you can use the project operator to explicitly define the schema of the output data.

    Here is an example of how you can modify your query:

    cluster('dummy.kusto.windows.net').database('DummyDB').AllMgmtSmsAccountTrace | project Column1: string, Column2: int, Column3: datetime | take 10
    

    In this example, the project operator is used to explicitly define the schema of the output data. You can replace Column1, Column2, and Column3 with the actual column names and data types of your output data.

    I hope this helps! Let me know if you have any further questions.