Move stripe.chunk_count to last position

pull/4702/head
Hadi Moshayedi 2021-02-11 16:47:12 -08:00
parent 1c4081ea5f
commit e690d8b79b
6 changed files with 49 additions and 29 deletions

View File

@ -139,9 +139,9 @@ typedef FormData_columnar_options *Form_columnar_options;
#define Anum_columnar_stripe_file_offset 3 #define Anum_columnar_stripe_file_offset 3
#define Anum_columnar_stripe_data_length 4 #define Anum_columnar_stripe_data_length 4
#define Anum_columnar_stripe_column_count 5 #define Anum_columnar_stripe_column_count 5
#define Anum_columnar_stripe_chunk_count 6 #define Anum_columnar_stripe_chunk_row_count 6
#define Anum_columnar_stripe_chunk_row_count 7 #define Anum_columnar_stripe_row_count 7
#define Anum_columnar_stripe_row_count 8 #define Anum_columnar_stripe_chunk_count 8
/* constants for columnar.chunk_group */ /* constants for columnar.chunk_group */
#define Natts_columnar_chunkgroup 4 #define Natts_columnar_chunkgroup 4
@ -633,9 +633,9 @@ InsertStripeMetadataRow(uint64 storageId, StripeMetadata *stripe)
Int64GetDatum(stripe->fileOffset), Int64GetDatum(stripe->fileOffset),
Int64GetDatum(stripe->dataLength), Int64GetDatum(stripe->dataLength),
Int32GetDatum(stripe->columnCount), Int32GetDatum(stripe->columnCount),
Int32GetDatum(stripe->chunkCount),
Int32GetDatum(stripe->chunkRowCount), Int32GetDatum(stripe->chunkRowCount),
Int64GetDatum(stripe->rowCount) Int64GetDatum(stripe->rowCount),
Int32GetDatum(stripe->chunkCount)
}; };
Oid columnarStripesOid = ColumnarStripeRelationId(); Oid columnarStripesOid = ColumnarStripeRelationId();

View File

@ -21,9 +21,9 @@ CREATE TABLE stripe (
file_offset bigint NOT NULL, file_offset bigint NOT NULL,
data_length bigint NOT NULL, data_length bigint NOT NULL,
column_count int NOT NULL, column_count int NOT NULL,
chunk_count int NOT NULL,
chunk_row_count int NOT NULL, chunk_row_count int NOT NULL,
row_count bigint NOT NULL, row_count bigint NOT NULL,
chunk_group_count int NOT NULL,
PRIMARY KEY (storage_id, stripe_num) PRIMARY KEY (storage_id, stripe_num)
) WITH (user_catalog_table = true); ) WITH (user_catalog_table = true);

View File

@ -55,5 +55,15 @@ WITH a as (
), c as ( ), c as (
(TABLE a EXCEPT TABLE b) UNION (TABLE b EXCEPT TABLE a) UNION (TABLE a EXCEPT TABLE b) UNION (TABLE b EXCEPT TABLE a) UNION
(TABLE a EXCEPT TABLE columnar.chunk_group) UNION (TABLE columnar.chunk_group EXCEPT TABLE a) (TABLE a EXCEPT TABLE columnar.chunk_group) UNION (TABLE columnar.chunk_group EXCEPT TABLE a)
), d as (
SELECT storage_id, stripe_num, count(*) as chunk_group_count
FROM columnar.chunk_group
GROUP BY 1,2
), e as (
SELECT storage_id, stripe_num, chunk_group_count
FROM columnar.stripe
), f as (
(TABLE d EXCEPT TABLE d) UNION (TABLE e EXCEPT TABLE d)
) )
SELECT count(*) = 0 AS consistent FROM c; SELECT (SELECT count(*) = 0 FROM c) AND
(SELECT count(*) = 0 FROM f) as consistent;

View File

@ -173,16 +173,16 @@ INSERT INTO zero_col_heap SELECT * FROM zero_col_heap;
INSERT INTO zero_col_heap SELECT * FROM zero_col_heap; INSERT INTO zero_col_heap SELECT * FROM zero_col_heap;
INSERT INTO zero_col_heap SELECT * FROM zero_col_heap; INSERT INTO zero_col_heap SELECT * FROM zero_col_heap;
INSERT INTO zero_col SELECT * FROM zero_col_heap; INSERT INTO zero_col SELECT * FROM zero_col_heap;
SELECT relname, stripe_num, row_count FROM columnar.stripe a, pg_class b SELECT relname, stripe_num, chunk_group_count, row_count FROM columnar.stripe a, pg_class b
WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col' WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col'
ORDER BY 1,2,3; ORDER BY 1,2,3,4;
relname | stripe_num | row_count relname | stripe_num | chunk_group_count | row_count
--------------------------------------------------------------------- ---------------------------------------------------------------------
zero_col | 1 | 1 zero_col | 1 | 1 | 1
zero_col | 2 | 1 zero_col | 2 | 1 | 1
zero_col | 3 | 1 zero_col | 3 | 1 | 1
zero_col | 4 | 1 zero_col | 4 | 1 | 1
zero_col | 5 | 64 zero_col | 5 | 7 | 64
(5 rows) (5 rows)
SELECT relname, stripe_num, value_count FROM columnar.chunk a, pg_class b SELECT relname, stripe_num, value_count FROM columnar.chunk a, pg_class b

View File

@ -59,5 +59,15 @@ WITH a as (
), c as ( ), c as (
(TABLE a EXCEPT TABLE b) UNION (TABLE b EXCEPT TABLE a) UNION (TABLE a EXCEPT TABLE b) UNION (TABLE b EXCEPT TABLE a) UNION
(TABLE a EXCEPT TABLE columnar.chunk_group) UNION (TABLE columnar.chunk_group EXCEPT TABLE a) (TABLE a EXCEPT TABLE columnar.chunk_group) UNION (TABLE columnar.chunk_group EXCEPT TABLE a)
), d as (
SELECT storage_id, stripe_num, count(*) as chunk_group_count
FROM columnar.chunk_group
GROUP BY 1,2
), e as (
SELECT storage_id, stripe_num, chunk_group_count
FROM columnar.stripe
), f as (
(TABLE d EXCEPT TABLE d) UNION (TABLE e EXCEPT TABLE d)
) )
SELECT count(*) = 0 AS consistent FROM c; SELECT (SELECT count(*) = 0 FROM c) AND
(SELECT count(*) = 0 FROM f) as consistent;

View File

@ -128,9 +128,9 @@ INSERT INTO zero_col_heap SELECT * FROM zero_col_heap;
INSERT INTO zero_col SELECT * FROM zero_col_heap; INSERT INTO zero_col SELECT * FROM zero_col_heap;
SELECT relname, stripe_num, row_count FROM columnar.stripe a, pg_class b SELECT relname, stripe_num, chunk_group_count, row_count FROM columnar.stripe a, pg_class b
WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col' WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col'
ORDER BY 1,2,3; ORDER BY 1,2,3,4;
SELECT relname, stripe_num, value_count FROM columnar.chunk a, pg_class b SELECT relname, stripe_num, value_count FROM columnar.chunk a, pg_class b
WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col' WHERE columnar_relation_storageid(b.oid)=a.storage_id AND relname = 'zero_col'