diff --git a/data-explorer/kusto/query/node-id.md b/data-explorer/kusto/query/node-id.md new file mode 100644 index 0000000000..1d48ae033e --- /dev/null +++ b/data-explorer/kusto/query/node-id.md @@ -0,0 +1,80 @@ +--- +title: node_id (graph function) +description: This article describes the node_id() function. +ms.topic: reference +ms.date: 10/29/2025 +--- + +# node_id() (graph function) + +> [!INCLUDE [applies](../includes/applies-to-version/applies.md)] [!INCLUDE [fabric](../includes/applies-to-version/fabric.md)] [!INCLUDE [azure-data-explorer](../includes/applies-to-version/azure-data-explorer.md)] + +The `node_id` function calculates the graph node identifier as it was set by the user either in make-graph or graph model. + +> [!NOTE] +> This function is used with the [`graph-match`](graph-match-operator.md) and [`graph-shortest-paths`](graph-shortest-paths-operator.md) operators. + +> [!WARNING] +> This feature is currently in public preview. Functionality and syntax are subject to change before General Availability. + +## Syntax + +`node_id([`*node*`])` + +[!INCLUDE [syntax-conventions-note](../includes/syntax-conventions-note.md)] + +## Parameters + +| Name | Type | Required | Description | +|---|---|---|---| +| *node* | `string` | | The reference to a graph node variable in a graph pattern.
Don't pass any parameters when used inside [all()](all-graph-function.md), [any()](any-graph-function.md), and [map()](map-graph-function.md) graph functions, with [inner_nodes()](inner-nodes-graph-function.md).| + +## Returns + +Returns the node ID string representation of the input node or of all inner nodes, when used inside [all()](all-graph-function.md), [any()](any-graph-function.md), and [map()](map-graph-function.md) functions with [inner_nodes()](inner-nodes-graph-function.md). + +## Example + +The following example creates a graph to analyze a hierarchical structure of employees and their managers. + +:::moniker range="azure-data-explorer" +> [!div class="nextstepaction"] +> Run the query +::: moniker-end + +```kusto +let employees = datatable(name:string, age:long) +[ +"Alice", 32, +"Bob", 31, +"Eve", 27, +]; +let reports = datatable(employee:string, manager:string) +[ +"Bob", "Alice", +"Chris", "Alice", +"Eve", "Bob", +]; +reports +| make-graph employee --> manager with employees on name +| graph-match (employee)-[reports*1..3]->(manager) + where node_id(employee) startswith "E" + project manager1 = node_id(manager), manager2 = map(inner_nodes(reports), node_id()) +``` + +**Output** + +| manager_1 | manager_2 | +|--|--| +| Bob | [] | +| Alice | ["Bob"] + + +## Related content + +* [Graph overview](graph-semantics-overview.md) +* [Graph operators](graph-operators.md) +* [graph-match operator](graph-match-operator.md) +* [node-degree-out](node-degree-out.md) +* [any()](any-graph-function.md) +* [map()](map-graph-function.md) diff --git a/data-explorer/kusto/query/toc.yml b/data-explorer/kusto/query/toc.yml index 15aafb26ea..0c4ef2a575 100644 --- a/data-explorer/kusto/query/toc.yml +++ b/data-explorer/kusto/query/toc.yml @@ -1325,6 +1325,9 @@ items: - name: node_degree_out() displayName: graph, node, Node degree out node_degree_out, outdegree node_degree_out href: node-degree-out.md + - name: node_id() + displayName: graph, node, Node Id + href: node-id.md - name: Visualization items: - name: Overview