跳到正文

TimeBoundary 查询 ​

INFO

Apache® Druid 支持两种查询语言:Druid SQL 和原生查询。 本文档介绍的查询类型 仅在原生查询语言中可用。

时间边界(time boundary)查询返回数据集中最早和最晚的数据点。语法如下:

json
{
    "queryType" : "timeBoundary",
    "dataSource": "sample_datasource",
    "bound"     : < "maxTime" | "minTime" > # optional, defaults to returning both timestamps if not set
    "filter"    : { "type": "and", "fields": [<filter>, <filter>, ...] } # optional
}

时间边界查询主要包含 3 个部分:

属性描述是否必需
queryType该字符串应始终为 "timeBoundary";Apache® Druid 首先根据它来确定如何解析该查询是
dataSource一个字符串或对象,定义要查询的数据源,非常类似于关系型数据库中的表。更多信息请参阅 DataSource。是
bound可选,设置为 maxTime 或 minTime 时,只返回最晚或最早的时间戳。如果未设置,默认两者都返回否
filter请参阅过滤器否
context请参阅查询上下文参考否

结果的格式如下:

json
[ {
  "timestamp" : "2013-05-09T18:24:00.000Z",
  "result" : {
    "minTime" : "2013-05-09T18:24:00.000Z",
    "maxTime" : "2013-05-09T18:37:00.000Z"
  }
} ]

基于 Apache License 2.0 许可证发布。