Skip to content

Commit 8564339

Browse files
committed
PAX: support varchar min/max operator
The operator of varchar does not exist in pg_operator.dat, but it have same oper with text. This is because the type which can be cast picked in the oper() function. Current change support the varchar min/max operator in PAX.
1 parent 7523cf0 commit 8564339

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

contrib/pax_storage/expected/statistics.out

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set default_table_access_method = pax;
33
-- Test with small group
44
--
55
set pax_max_tuples_per_group = 10;
6-
-- overview
6+
-- test min/max type support
77
create table t1(v1 int, v2 text, v3 float8, v4 bool) with (minmax_columns='v1,v2,v3,v4');
88
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'v1' as the Cloudberry Database data distribution key for this table.
99
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
@@ -17,6 +17,19 @@ select * from get_pax_aux_table('t1');
1717
(3 rows)
1818

1919
drop table t1;
20+
create table t2(v1 bpchar, v2 bpchar(20), v3 varchar(20), v4 varchar(20)) with (minmax_columns='v1,v2,v3,v4');
21+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'v1' as the Cloudberry Database data distribution key for this table.
22+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
23+
insert into t2 select i::bpchar,i::bpchar,i::varchar, i::varchar from generate_series(1, 1000)i;
24+
select * from get_pax_aux_table('t2');
25+
ptblockname | pttupcount | ptstatistics | ptexistvisimap | ptexistexttoast | ptisclustered
26+
-------------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+-----------------+---------------
27+
0 | 322 | [(false,false),(322),(1,998),None],[(false,false),(322),(1 ,998 ),None],[(false,false),(322),(1,998),None],[(false,false),(322),(1,998),None] | f | f | f
28+
0 | 340 | [(false,false),(340),(1000,999),None],[(false,false),(340),(1000 ,999 ),None],[(false,false),(340),(1000,999),None],[(false,false),(340),(1000,999),None] | f | f | f
29+
0 | 338 | [(false,false),(338),(101,997),None],[(false,false),(338),(101 ,997 ),None],[(false,false),(338),(101,997),None],[(false,false),(338),(101,997),None] | f | f | f
30+
(3 rows)
31+
32+
drop table t2;
2033
-- test `hasnull/allnull`/`count`, not need setting the minmax_columns
2134
create table t1(v1 int, v2 float8);
2235
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'v1' as the Cloudberry Database data distribution key for this table.

contrib/pax_storage/sql/statistics.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ set default_table_access_method = pax;
66
--
77
set pax_max_tuples_per_group = 10;
88

9-
-- overview
9+
-- test min/max type support
1010
create table t1(v1 int, v2 text, v3 float8, v4 bool) with (minmax_columns='v1,v2,v3,v4');
1111
insert into t1 select i,i::text,i::float8, i % 2 > 0 from generate_series(1, 1000)i;
1212
select * from get_pax_aux_table('t1');
1313
drop table t1;
1414

15+
create table t2(v1 bpchar, v2 bpchar(20), v3 varchar(20), v4 varchar(20)) with (minmax_columns='v1,v2,v3,v4');
16+
insert into t2 select i::bpchar,i::bpchar,i::varchar, i::varchar from generate_series(1, 1000)i;
17+
select * from get_pax_aux_table('t2');
18+
drop table t2;
19+
1520
-- test `hasnull/allnull`/`count`, not need setting the minmax_columns
1621
create table t1(v1 int, v2 float8);
1722

contrib/pax_storage/src/cpp/storage/oper/pax_oper.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,18 @@ std::map<OperMinMaxKey, OperMinMaxFunc> min_max_opers = {
814814
INIT_MIN_MAX_OPER(BPCHAROID, BPCHAROID, BTGreaterStrategyNumber,
815815
textop::BpCharGT),
816816

817+
// oper(varchar, varchar)
818+
INIT_MIN_MAX_OPER(VARCHAROID, VARCHAROID, BTLessStrategyNumber,
819+
textop::TextLT),
820+
INIT_MIN_MAX_OPER(VARCHAROID, VARCHAROID, BTLessEqualStrategyNumber,
821+
textop::TextLE),
822+
INIT_MIN_MAX_OPER(VARCHAROID, VARCHAROID, BTEqualStrategyNumber,
823+
textop::TextEQ),
824+
INIT_MIN_MAX_OPER(VARCHAROID, VARCHAROID, BTGreaterEqualStrategyNumber,
825+
textop::TextGE),
826+
INIT_MIN_MAX_OPER(VARCHAROID, VARCHAROID, BTGreaterStrategyNumber,
827+
textop::TextGT),
828+
817829
// oper(numeric, numeric)
818830
INIT_MIN_MAX_OPER(NUMERICOID, NUMERICOID, BTLessStrategyNumber,
819831
numericop::NumericLT),
@@ -827,8 +839,6 @@ std::map<OperMinMaxKey, OperMinMaxFunc> min_max_opers = {
827839
numericop::NumericGT),
828840

829841
// FIXME(jiaqizho): support below oper in the feature
830-
// BPCHAROID
831-
// VARCHAROID
832842
// TIMESTAMPTZOID
833843
// TIMEOID
834844
// TIMESTAMPOID

0 commit comments

Comments
 (0)