我正在运行一个Timescale数据库,并且正在使用JOOQ访问数据。
我正在将gapfill()
用于
dslContext
.select(Routines.timeBucketGapfill5(
Routines.createInterval(DURATION), table.TIME, null, null).as(FieldName.TIME_BUCKET),
ifnull(count(table.STATUS), 0).as(FieldName.STATUS))
.from(table)
.where(table.ID.in(ids)
.and(table.TIME.ge(Timestamp.from(Instant.now().minus(Duration.ofSeconds(DURATION)))))
.and(table.TIME.le(Timestamp.from(Instant.now())))
.and(table.STATUS.eq(status)))
.groupBy(field(FieldName.TIME_BUCKET))
.fetch()
有时我得到一个
org.postgresql.util.PSQLException: ERROR: invalid time_bucket_gapfill argument: start cannot be NULL
Hinweis: You can either pass start and finish as arguments or in the WHERE clause
如果我总是有一个带有equalsEquals和lessEquals的where子句,start
如何为NULL?
我能够记录SQL语句。如果我直接在数据库上运行该查询,它将正常工作。
select "public"."time_bucket_gapfill"("bucket_width" := cast("public"."create_interval"("seconds" := 43200) as "pg_catalog"."interval"), "ts" := cast("public"."device_health"."time" as timestamp), "start" := cast(null as timestamp), "finish" := cast(null as timestamp)) as "time_bucket", coalesce(count("public"."device_health"."health"), 0) as "health" from "public"."device_health" where ("public"."device_health"."device" in ('700004', '700009', '700008', '700005', '700007', '700000', '700003', '700001', '700002', '700006') and "public"."device_health"."time" >= timestamp '2020-03-11 13:59:20.0564238' and "public"."device_health"."time" <= timestamp '2020-03-25 13:59:20.0564238' and "public"."device_health"."health" = 'OK') group by time_bucket
如果在gapfill调用中传递与start
和finish
可选参数相同的参数,是否会看到相同的错误?您是否能够捕获JOOQ正在合成的实际SQL?
(此外,对于更多的来回帮助,您可能会发现slack.timescale.com很有帮助。)