GTree Function | Teradata Vantage - GTree (ML Engine) - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

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 (ML Engine), 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 syntax elements is input to the GTree function differently, as the following table shows.

GTree Analogs of NTree Syntax Elements
SQL-MR Function NTree Syntax Element 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 syntax element 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 syntax element.
Result GTree gets the aggregate functions and their aliases from its Results syntax element, which is similar to the NTree Result syntax element. However, the parser that GTree uses requires that you enclose each aggregate function and its alias in quotation marks.