types.isType() 函数
types.isType()
测试值是否为指定的类型。
函数类型签名
(type: string, v: A) => bool where A: Basic
有关更多信息,请参阅 函数类型签名。
参数
v
(必需) 要测试的值。
type
(必需) 描述要检查的类型的字符串。
支持的类型:
- string
- bytes
- int
- uint
- float
- bool
- time
- duration
- regexp
示例
按值类型过滤
import "types"
data
|> filter(fn: (r) => types.isType(v: r._value, type: "string"))
根据类型聚合或选择数据
import "types"
nonNumericData =
data
|> filter(
fn: (r) =>
types.isType(v: r._value, type: "string") or types.isType(
v: r._value,
type: "bool",
),
)
|> aggregateWindow(every: 30s, fn: last)
numericData =
data
|> filter(
fn: (r) =>
types.isType(v: r._value, type: "int") or types.isType(v: r._value, type: "float"),
)
|> aggregateWindow(every: 30s, fn: mean)
union(tables: [nonNumericData, numericData])
此页内容是否有帮助?
感谢您的反馈!