追加到数据集节点
概述
Append to Dataset节点用于向指定数据集追加一行数据。当您想要向现有数据集添加新数据以进行进一步处理或分析时,此节点特别有用。
节点在运行图时需要上下文中有一个可用的数据集提供者。数据集提供者负责管理数据集的存储和检索。在Rivet应用程序中,数据集提供者会自动为您处理。
有关数据集的更多信息,请参阅用户指南中的Data Studio部分。
- 输入
- 输出
- 编辑器设置
输入项
标题 | 数据类型 | 描述 | 默认值 | 备注 |
---|---|---|---|---|
Data | string or string[] | The data to be appended to the dataset. Each entry in the array corresponds to a column in the new row in the dataset. | (required) | The input will be coerced into a string array if it is not a string array. |
ID | string | The ID for the new row of data. If not provided, a new ID will be generated. | (Automatically generated) | The input will be coerced into a string if it is not a string. |
Embedding | vector | An optional vector that can be associated with the new row of data. | (empty) | The input will be coerced into a vector if it is not a vector. |
Dataset ID | string | The ID of the dataset to append to. This input is only available if Use Dataset ID Input is enabled. | (required if if the input toggle for Dataset ID is enabled) | The input will be coerced into a string if it is not a string. |
输出
标题 | 数据类型 | 描述 | 备注 |
---|---|---|---|
Dataset | object | The new row of data that was appended to the dataset. | The output will be an object containing the ID, data, and embedding of the new row. |
ID | string | The ID of the dataset that the data was appended to. | The output will be the same as the Dataset ID input or the Dataset ID specified in the settings. |
编辑器设置
设置 | 描述 | 默认值 | 使用输入切换 | 输入数据类型 |
---|---|---|---|---|
Dataset | The ID of the dataset to append to. | (required) | Yes | string |
使用数据集ID输入 | 如果启用,可以通过数据集ID输入端口提供数据集ID。 | False | No | N/A |
示例1:向数据集追加数据
- 创建一个Array Node并将值设置为
["John Doe", "30", "Engineer"]
。 - 在Data Studio中,创建一个ID为
employees
的新数据集。 - 创建一个Append to Dataset节点并将Dataset ID设置为
employees
。 - 将Array节点连接到Append to Dataset节点的
Data
输入端口。 - 运行图表。Append to Dataset节点的
Dataset
输出应包含已追加到employees
数据集的新数据行。
错误处理
如果运行图表时上下文中数据集提供程序不可用,Append to Dataset节点将报错。如果未提供Data
输入,它也会报错。
常见问题
问:什么是数据集提供者?
A: 数据集提供者是一个负责管理数据集存储和检索的对象。当图表运行时,它会被传递给上下文。数据集提供者必须实现DatasetProvider
接口,该接口包含获取、存放和删除数据集的方法。更多信息请参阅API参考文档。
问:我可以一次性向多个数据集追加数据吗?
答:不可以,Append to Dataset节点每次只能向一个数据集追加数据。如果您需要向多个数据集追加数据,可以使用多个Append to Dataset节点。
问:如果数据集不存在会发生什么?
A: 如果数据集不存在,Append to Dataset Node 将会报错。