The GTree function follows all paths in a graph, starting from a given set of root vertices, and calculates specified aggregate functions along those paths.
The GTree function is similar to the function NTree, but GTree is implemented using the SQL-GR engine. The SQL-GR engine allows the GTree function to traverse arbitrary graphs.
Some information in NTree arguments is input to the GTree function differently, as the following table shows.
|SQL-MR Function NTree Argument||SQL-GR Function GTree Analog|
|Root_Node||GTree gets the root nodes of the trees from the input table root.|
|Node_ID||GTree gets the nodes from the partition keys for the input tables vertices, edges, and root. The name of these keys can differ, but each partition must have the same number of keys and corresponding keys must have the same data type.|
|Parent_ID||The input table edges and the TargetKey argument define the parent ID. If the TargetKey specifies a vertex, then GTree finds its parent in the corresponding partition key entries.|
|Mode||To change the direction in which GTree traverses the graph, reverse the direction of the edges by switching the columns in the edges table partition key with the columns specified by the TargetKey argument.|
|Result||GTree gets the aggregate functions and their aliases from its Results argument, which is similar to the NTree Result argument. However, the parser that GTree uses requires that you enclose each aggregate function and its alias in quotation marks.|