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