Graph Match operator error when project is not specified

Waruna Yapa 0 Reputation points Microsoft Employee
2024-05-10T22:37:39.98+00:00

I'm going through examples here: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/graph-match-operator

I'm attempting to use an anonymous node and edge combinations to get all matching nodes with the pattern

()--[]--()

which to my understanding is valid.

I'm using the example here: https://dataexplorer.azure.com/clusters/help/databases/Samples

with the query

 
let employees = datatable(name:string, age:long) 
[ 
 "Alice", 32,  
 "Bob", 31,  
 "Eve", 27,  
 "Joe", 29,  
 "Chris", 45, 
 "Alex", 35,
 "Ben", 23,
 "Richard", 39,
]; 
let reports = datatable(employee:string, manager:string) 
[ 
 "Bob", "Alice",  
 "Chris", "Alice",  
 "Eve", "Bob",
 "Ben", "Chris",
 "Joe", "Alice", 
 "Richard", "Bob"
]; 
reports 
| make-graph employee --> manager with employees on name 
| graph-match ()<-[]-()


From the documents, it seems like the projection should be optional but the query fails with

Semantic Error graph-match operator: missing project clause

Is there an example of how to use anonymous nodes and variables to match all entries that match the pattern?

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.
487 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 31,721 Reputation points Microsoft Employee
    2024-05-13T11:46:49.5233333+00:00

    Hi @Waruna Yapa ,

    Thanks for using Microsoft Q&A platform .

    I see, the error is likely occurring because the query doesn't specify what should be projected after the graph-match operation. To avoid the "missing project clause" error, you need to include a projection statement after the graph-match operation.

    Could you please specify where it's mentioned that projection is optional in the document you shared.

    Kindly try the below code , this query should match all entries that match the pattern ()--[]--().

    let employees = datatable(name:string, age:long) 
    [ 
     "Alice", 32,  
     "Bob", 31,  
     "Eve", 27,  
     "Joe", 29,  
     "Chris", 45, 
     "Alex", 35,
     "Ben", 23,
     "Richard", 39,
    ]; 
    let reports = datatable(employee:string, manager:string) 
    [ 
     "Bob", "Alice",  
     "Chris", "Alice",  
     "Eve", "Bob",
     "Ben", "Chris",
     "Joe", "Alice", 
     "Richard", "Bob"
    ]; 
    reports 
    | make-graph employee --> manager with employees on name 
    | graph-match (A)<-[]-(B)
      project manager=A.name , emp=B.name
    

    Hope it helps. Kindly accept the answer by clicking on `Accept answer button. Thankyou