其他 SQL 函数
InfluxDB Clustered SQL 实现支持以下其他函数,用于执行各种操作
arrow_cast
将值转换为特定的 Arrow 数据类型。
arrow_cast(expression, datatype)
参数
- expression: 要转换的表达式。可以是常量、列或函数,以及算术或字符串运算符的任意组合。
- datatype: 要转换成的 Arrow 数据类型。
查看 arrow_cast
查询示例
以下示例使用 InfluxDB 入门教程 中提供的示例数据集。
SELECT
arrow_cast(time, 'Int64') AS time,
arrow_cast(temp, 'Utf8') AS temp,
arrow_cast(co, 'Float64')AS co
FROM home
LIMIT 1
time | temp | co |
---|
1641024000000000000 | 21.0 | 0 |
arrow_typeof
返回表达式的底层 Arrow 数据类型
参数
- expression: 要评估的表达式。可以是常量、列或函数,以及算术或字符串运算符的任意组合。
查看 arrow_typeof
查询示例
以下示例使用 InfluxDB 入门教程 中提供的示例数据集。
SELECT
arrow_typeof(time) AS time,
arrow_typeof(room) AS room,
arrow_typeof(temp) AS temp,
arrow_typeof(co) AS co
FROM home
LIMIT 1
time | room | temp | co |
---|
Timestamp(纳秒, None) | Dictionary(Int32, Utf8) | Float64 | Int64 |
interpolate
通过从现有值插值来填充指定聚合列中的空值。 必须与 date_bin_gapfill
一起使用。
interpolate(aggregate_expression)
参数
- aggregate_expression: 对指定表达式的聚合操作。该操作可以使用任何 聚合函数。 表达式可以是常量、列或函数,以及聚合函数支持的算术运算符的任意组合。
date_bin_gapfill, locf
查看 interpolate
查询示例
以下示例使用 InfluxDB 入门教程 中提供的示例数据集。
SELECT
date_bin_gapfill(INTERVAL '30 minutes', time) as _time,
room,
interpolate(avg(temp))
FROM home
WHERE
time >= '2022-01-01T08:00:00Z'
AND time <= '2022-01-01T10:00:00Z'
GROUP BY _time, room
_time | room | AVG(home.temp) |
---|
2022-01-01T08:00:00Z | Kitchen | 21 |
2022-01-01T08:30:00Z | Kitchen | 22 |
2022-01-01T09:00:00Z | Kitchen | 23 |
2022-01-01T09:30:00Z | Kitchen | 22.85 |
2022-01-01T10:00:00Z | Kitchen | 22.7 |
2022-01-01T08:00:00Z | Living Room | 21.1 |
2022-01-01T08:30:00Z | Living Room | 21.25 |
2022-01-01T09:00:00Z | Living Room | 21.4 |
2022-01-01T09:30:00Z | Living Room | 21.6 |
2022-01-01T10:00:00Z | Living Room | 21.8 |
locf
通过向前携带最后观察到的值来填充指定聚合列中的空值。 必须与 date_bin_gapfill
一起使用。
LOCF 是“last observation carried forward”(最后一次观察值向前结转)的首字母缩写。
locf(aggregate_expression)
参数
- aggregate_expression: 对指定表达式的聚合操作。该操作可以使用任何 聚合函数。 表达式可以是常量、列或函数,以及聚合函数支持的算术运算符的任意组合。
date_bin_gapfill, interpolate
查看 locf
查询示例
以下示例使用 InfluxDB 入门教程 中提供的示例数据集。
SELECT
date_bin_gapfill(INTERVAL '30 minutes', time) as _time,
room,
locf(avg(temp))
FROM home
WHERE
time >= '2022-01-01T08:00:00Z'
AND time <= '2022-01-01T10:00:00Z'
GROUP BY _time, room
_time | room | AVG(home.temp) |
---|
2022-01-01T08:00:00Z | Kitchen | 21 |
2022-01-01T08:30:00Z | Kitchen | 21 |
2022-01-01T09:00:00Z | Kitchen | 23 |
2022-01-01T09:30:00Z | Kitchen | 23 |
2022-01-01T10:00:00Z | Kitchen | 22.7 |
2022-01-01T08:00:00Z | Living Room | 21.1 |
2022-01-01T08:30:00Z | Living Room | 21.1 |
2022-01-01T09:00:00Z | Living Room | 21.4 |
2022-01-01T09:30:00Z | Living Room | 21.4 |
2022-01-01T10:00:00Z | Living Room | 21.8 |
支持和反馈
感谢您成为我们社区的一份子! 我们欢迎并鼓励您提供关于 InfluxDB Clustered 和本文档的反馈和错误报告。 如需获得支持,请使用以下资源
拥有年度或支持合同的客户可以联系 InfluxData 支持。