Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
The any() graph function evaluates a condition for each edge or inner node along a variable length path.
Note
This function is used with the graph-match and graph-shortest-paths operators.
Syntax
any(edge, condition)
any(inner_nodes(edge), condition)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| edge | string |
✔️ | A variable length edge from the graph-match operator or graph-shortest-paths operator pattern. For more information, see Graph pattern notation. |
| condition | string |
✔️ | A Boolean expression composed of properties of the edge or inner node, when inner_nodes is used, in the variable length edge. A property is referenced using the property name directly. The expression is evaluated for each edge or inner node in the variable length edge. |
Returns
Returns true if the condition evaluates to true for at least one edge or inner node, when inner_nodes is used, in the variable length edge. Otherwise, it returns false.
For zero length paths, the condition evaluates to false.
Examples
The following example uses the Locations and Routes data tables to construct a graph that finds paths from a source location to a destination location through a route. It uses any() function to find paths that uses "Train" transportation method at least once. It returns the source location name, destination location name and transportation methods along the route.
// Locations table (nodes)
let Locations = datatable(LocationName: string, LocationType: string) [
"New York", "City",
"San Francisco", "City",
"Chicago", "City",
"Los Angeles", "City",
"Seattle", "Warehouse"
];
// Routes table (edges)
let Routes = datatable(OriginLocationID: string, DestinationLocationID: string, TransportMode: string) [
"New York", "San Francisco", "Truck",
"New York", "Chicago", "Train",
"San Francisco", "Los Angeles", "Truck",
"Chicago", "Seattle", "Train",
"Los Angeles", "New York", "Truck",
"Seattle", "San Francisco", "Train"
];
Routes
| make-graph OriginLocationID --> DestinationLocationID with Locations on LocationName
| graph-match (src)-[route*1..2]->(dest)
where any(route, TransportMode == "Train")
project src.LocationName,
dest.LocationName,
route_TransportModes = map(route, TransportMode)
Output
| src_LocationName | dest_LocationName | route_TransportModes |
|---|---|---|
| Seattle | San Francisco | ["Train"] |
| Chicago | Seattle | ["Train"] |
| New York | Chicago | ["Train"] |
| Seattle | Los Angeles | [ "Train", "Truck" ] |
| Chicago | San Francisco | [ "Train", "Train" ] |
| New York | Seattle | [ "Train", "Train" ] |
| Los Angeles | Chicago | [ "Truck", "Train" ] |
The following example shows how to use the graph-shortest-paths operator with the any() and inner_nodes functions to find a path between two stations in a transportation network. The query constructs a graph from the connections data and finds the shortest path from the "South-West" station to the "North" station, passing through at least one station where Wi-Fi is available.
let connections = datatable(from_station:string, to_station:string, line:string)
[
"Central", "North", "red",
"North", "Central", "red",
"Central", "South", "red",
"South", "Central", "red",
"South", "South-West", "red",
"South-West", "South", "red",
"South-West", "West", "red",
"West", "South-West", "red",
"Central", "East", "blue",
"East", "Central", "blue",
"Central", "West", "blue",
"West", "Central", "blue",
];
let stations = datatable(station:string, wifi: bool)
[
"Central", true,
"North", false,
"South", false,
"South-West", true,
"West", true,
"East", false
];
connections
| make-graph from_station --> to_station with stations on station
| graph-match cycles=none (start)-[connections*2..5]->(destination)
where start.station == "South-West" and
destination.station == "North" and
any(inner_nodes(connections), wifi)
project from = start.station,
stations = strcat_array(map(inner_nodes(connections), station), "->"),
to = destination.station
Output
| from | stations | to |
|---|---|---|
| South-West | South->Central | North |
| South-West | West->Central | North |