findRecord() 函数
findRecord() 返回一个在指定索引处的行,作为流中第一个表的记录,该表符合指定的谓词函数。
如果未找到表,或者索引超出范围,函数返回一个空记录。
函数类型签名
(<-tables: stream[B], fn: (key: A) => bool, idx: int) => B where A: Record, B: Record
有关更多信息,请参见 Function type signatures。
参数
索引
(必填) 要提取的记录索引。
函数
(必需) 用于评估输入表组键的谓词函数。
findColumn() 使用第一个解析为 true 的表。谓词函数需要一个 key 参数,表示每个输入表的组键作为记录。
表格
输入数据。默认是管道转发数据 (<-).
示例
将一行提取为记录
import "sampledata"
sampledata.int()
|> findRecord(
fn: (key) => key.tag == "t1",
idx: 0,
)// Returns {_time: 2021-01-01T00:00:00.000000000Z, _value: -2, tag: t1}