graph-to-table
运算符将图形中的节点或边导出到表。
语法
节点
G |
graph-to-table
nodes
[ with_node_id=
ColumnName ]
边缘
G |
graph-to-table
edges
[ with_source_id=
ColumnName ] [ with_target_id=
ColumnName ] [ as
TableName ]
节点和边
G |
graph-to-table
nodes
as
NodesTableName [ with_node_id=
ColumnName ],
edges
as
EdgesTableName [ with_source_id=
ColumnName ] [ with_target_id=
ColumnName ]
参数
客户 | 类型 | 必需 | 说明 |
---|---|---|---|
G | string |
✔️ | 输入图源。 |
NodesTableName | string |
导出的节点表的名称。 | |
EdgesTableName | string |
导出的边表的名称。 | |
ColumnName | string |
导出具有给定列名的节点哈希 ID、源节点哈希 ID 或目标节点哈希 ID。 |
返回
节点
graph-to-table
运算符返回表格结果,其中每一行对应于源图中的一个节点。 返回的列是节点的属性。 提供 with_node_id
时,节点哈希列的类型为 long
。
边缘
graph-to-table
运算符返回表格结果,其中每一行对应于源图中的一个边。 返回的列是节点的属性。 提供 with_source_id
或 with_target_id
时,节点哈希列的类型为 long
。
节点和边
graph-to-table
运算符返回两个表格结果,与前面的说明匹配。
示例
以下示例对运算符如何将边缘从图形导出到表的方式 graph-to-table
进行反规范。
with_source_id
和 with_target_id
参数导出每个边的源节点和目标节点的节点哈希。
let nodes = datatable(name:string, type:string, age:long)
[
"Alice", "Person", 23,
"Bob", "Person", 31,
"Eve", "Person", 17,
"Mallory", "Person", 29,
"Trent", "System", 99
];
let edges = datatable(source:string, destination:string, edge_type:string)
[
"Alice", "Bob", "communicatesWith",
"Alice", "Trent", "trusts",
"Bob", "Trent", "hasPermission",
"Eve", "Alice", "attacks",
"Mallory", "Alice", "attacks",
"Mallory", "Bob", "attacks"
];
edges
| make-graph source --> destination with nodes on name
| graph-to-table edges with_source_id=SourceId with_target_id=TargetId
输出
SourceId | TargetId | target | 目的地 | edge_type |
---|---|---|---|---|
-3122868243544336885 | -7133945255344544237 | 爱丽丝 | 鲍勃 | communicatesWith |
-3122868243544336885 | 2533909231875758225 | 爱丽丝 | 特 伦 特 | 信托 |
-7133945255344544237 | 2533909231875758225 | 鲍勃 | 特 伦 特 | hasPermission |
4363395278938690453 | -3122868243544336885 | 前夕 | 爱丽丝 | 攻击 |
3855580634910899594 | -3122868243544336885 | 马洛里 | 爱丽丝 | 攻击 |
3855580634910899594 | -7133945255344544237 | 马洛里 | 鲍勃 | 攻击 |
获取节点
下面的示例演示如何 graph-to-table
运算符将节点从图形导出到表。
with_node_id
参数导出节点哈希。
let nodes = datatable(name:string, type:string, age:long)
[
"Alice", "Person", 23,
"Bob", "Person", 31,
"Eve", "Person", 17,
"Trent", "System", 99
];
let edges = datatable(source:string, destination:string, edge_type:string)
[
"Alice", "Bob", "communicatesWith",
"Alice", "Trent", "trusts",
"Bob", "Trent", "hasPermission",
"Eve", "Alice", "attacks",
"Mallory", "Alice", "attacks",
"Mallory", "Bob", "attacks"
];
edges
| make-graph source --> destination with nodes on name
| graph-to-table nodes with_node_id=NodeId
输出
节点 ID | 姓名 | 类型 | 年龄 |
---|---|---|---|
-3122868243544336885 | 爱丽丝 | 人员 | 23 |
-7133945255344544237 | 鲍勃 | 人员 | 31 |
4363395278938690453 | 前夕 | 人员 | 十七 |
2533909231875758225 | 特 伦 特 | 系统 | 99 |
3855580634910899594 | 马洛里 |
以下示例使用 graph-to-table
运算符将节点和边缘从图形导出到表。
let nodes = datatable(name:string, type:string, age:long)
[
"Alice", "Person", 23,
"Bob", "Person", 31,
"Eve", "Person", 17,
"Trent", "System", 99
];
let edges = datatable(source:string, destination:string, edge_type:string)
[
"Alice", "Bob", "communicatesWith",
"Alice", "Trent", "trusts",
"Bob", "Trent", "hasPermission",
"Eve", "Alice", "attacks",
"Mallory", "Alice", "attacks",
"Mallory", "Bob", "attacks"
];
edges
| make-graph source --> destination with nodes on name
| graph-to-table nodes as N with_node_id=NodeId, edges as E with_source_id=SourceId;
N;
E
输出表 1
节点 ID | 姓名 | 类型 | 年龄 |
---|---|---|---|
-3122868243544336885 | 爱丽丝 | 人员 | 23 |
-7133945255344544237 | 鲍勃 | 人员 | 31 |
4363395278938690453 | 前夕 | 人员 | 十七 |
2533909231875758225 | 特 伦 特 | 系统 | 99 |
3855580634910899594 | 马洛里 |
输出表 2
SourceId | target | 目的地 | edge_type |
---|---|---|---|
-3122868243544336885 | 爱丽丝 | 鲍勃 | communicatesWith |
-3122868243544336885 | 爱丽丝 | 特 伦 特 | 信托 |
-7133945255344544237 | 鲍勃 | 特 伦 特 | hasPermission |
4363395278938690453 | 前夕 | 爱丽丝 | 攻击 |
3855580634910899594 | 马洛里 | 爱丽丝 | 攻击 |
3855580634910899594 | 马洛里 | 鲍勃 | 攻击 |