I have a Timescale DB running and am using JOOQ to access the data.
I am using gapfill()
for
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()
Sometimes I get a
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
How can start
be NULL if I always have a where clause with a greaterEquals and lessEquals?
I was able to log the SQL statement. If I run that query directly on the DB it works fine.
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