-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.

-- This test checks that the bloom sparse indexes survive the upgrade, so only
-- look at the bloom columns of the compressed chunk. Dumping the whole chunk
-- would also pull in the orderby sparse metadata, whose layout depends on the
-- version that compressed the chunk (minmax vs firstlast) and is not rewritten
-- on upgrade, which would cause a spurious diff unrelated to bloom indexes.
-- look at the bloom columns of one compressed chunk of the bloom hypertable.
\a
SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS type
FROM pg_attribute a
JOIN pg_type t ON t.oid = a.atttypid
WHERE a.attrelid = (
    SELECT cs.compress_relid
    FROM show_chunks('bloom') ch
    JOIN _timescaledb_catalog.compression_settings cs
        ON cs.relid = ch
    ORDER BY ch::text
    LIMIT 1
  )
  AND a.attnum > 0
  AND NOT a.attisdropped
  AND t.typname = 'bloom1'
ORDER BY a.attnum;
\a

