Thread: BUG #16753: 'expected 2-element int8 array' error while getting data using query with subquery

BUG #16753: 'expected 2-element int8 array' error while getting data using query with subquery

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      16753
Logged by:          Anjitha Paulose
Email address:      anjithapaul@gmail.com
PostgreSQL version: 12.5
Operating system:   Windows, Linux
Description:

I am using timescale db on top of postgres db. 
I am having table with mac_address and uptime. Mac address will be given
with colon or without colon. I am having the following data

   mac_address   |      timestamp      | uptime
-------------------+-----------------------------+----------
 AA:BB:45:TT:CC:34 | 2020-11-30 00:00:04 |    0
 112233445566         | 2020-11-30 00:00:06 |    0
 NN:CC:33:33:22:22 | 2020-11-30 00:00:05 |    0
 AA:BB:45:TT:CC:34 | 2020-11-30 00:30:04 |    1
 112233445566         | 2020-11-30 00:30:06 |    1
 NN:CC:33:33:22:22 | 2020-11-30 00:30:05 |    1 

I have created an hourly continous agggregate view to get average uptime in
each hour using below query

CREATE VIEW aggregated_data
WITH (timescaledb.continuous) AS
SELECT
time_bucket(INTERVAL '1 hour', timestamp) AS time_bucket,
mac_address,
AVG(uptime) AS avg_uptime
FROM data_table
GROUP BY time_bucket, mac_address
When I am trying to get data from aggregated_data table using below query, I
am getting error 'expected 2-element int8 array'

SELECT mac_address, time_bucket,
avg_uptime, count(*) over() as count
FROM aggregated_data
WHERE time_bucket >= '2020-10-28 18:00:00' and time_bucket < '2020-11-30
08:31:52'
AND mac_address IN (
          SELECT mac_address
          FROM aggregated_data
          WHERE time_bucket >= '2020-11-28 18:00:00' and time_bucket <
'2020-11-30 08:31:52'
          GROUP BY mac_address
          HAVING AVG(avg_uptime) > 0 AND AVG(avg_uptime) <=10
  )
ORDER BY time_bucket LIMIT 10 OFFSET 0


PG Bug reporting form <noreply@postgresql.org> writes:
> I am using timescale db on top of postgres db. 
> ...
> When I am trying to get data from aggregated_data table using below query, I
> am getting error 'expected 2-element int8 array'

I'm guessing you need to complain to the timescale folks;
I don't think there's any such error message in core Postgres.

            regards, tom lane