Skip to content

Commit f967400

Browse files
committed
Fix: pax operator without set null field also should not assert unimplemented sk_strategy
If current operator not support in pax operator. Then the all_null and has_null will be lost in file level statistics. Also Pax should not Assert(false) when accept a unimplemented sk_strategy. Current change also implements the bpchar operator.
1 parent eb33022 commit f967400

4 files changed

Lines changed: 75 additions & 1 deletion

File tree

contrib/pax_storage/src/cpp/storage/micro_partition_stats.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ void MicroPartitionStats::MergeTo(MicroPartitionStats *stats, TupleDesc desc) {
7878

7979
if (stats->status_[column_index] == 'n' ||
8080
stats->status_[column_index] == 'x') {
81+
// still need update all and has null
82+
if (stats_->GetAllNull(column_index) &&
83+
!stats->stats_->GetAllNull(column_index)) {
84+
stats_->SetAllNull(column_index, false);
85+
}
86+
87+
if (!stats_->GetHasNull(column_index) &&
88+
stats->stats_->GetHasNull(column_index)) {
89+
stats_->SetHasNull(column_index, true);
90+
}
8191
continue;
8292
}
8393

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,52 @@ bool TextGT(const void *l, const void *r, Oid collation) {
546546
return TextCmp(*(const text **)l, *(const text **)r, collation) > 0;
547547
}
548548

549+
static inline int
550+
BcTruelen(const BpChar *arg)
551+
{
552+
return bpchartruelen(VARDATA_ANY(arg), VARSIZE_ANY_EXHDR(arg));
553+
}
554+
555+
bool BpCharLT(const void *l, const void *r, Oid collation) {
556+
const BpChar *lbpchar = *(const BpChar **)l;
557+
const BpChar *rbpchar = *(const BpChar **)r;
558+
559+
return VarstrCmp(VARDATA_ANY(lbpchar), BcTruelen(lbpchar), VARDATA_ANY(rbpchar), BcTruelen(rbpchar),
560+
collation) < 0;
561+
}
562+
563+
bool BpCharLE(const void *l, const void *r, Oid collation) {
564+
const BpChar *lbpchar = *(const BpChar **)l;
565+
const BpChar *rbpchar = *(const BpChar **)r;
566+
567+
return VarstrCmp(VARDATA_ANY(lbpchar), BcTruelen(lbpchar), VARDATA_ANY(rbpchar), BcTruelen(rbpchar),
568+
collation) <= 0;
569+
}
570+
571+
bool BpCharEQ(const void *l, const void *r, Oid collation) {
572+
const BpChar *lbpchar = *(const BpChar **)l;
573+
const BpChar *rbpchar = *(const BpChar **)r;
574+
575+
return VarstrCmp(VARDATA_ANY(lbpchar), BcTruelen(lbpchar), VARDATA_ANY(rbpchar), BcTruelen(rbpchar),
576+
collation) == 0;
577+
}
578+
579+
bool BpCharGE(const void *l, const void *r, Oid collation) {
580+
const BpChar *lbpchar = *(const BpChar **)l;
581+
const BpChar *rbpchar = *(const BpChar **)r;
582+
583+
return VarstrCmp(VARDATA_ANY(lbpchar), BcTruelen(lbpchar), VARDATA_ANY(rbpchar), BcTruelen(rbpchar),
584+
collation) >= 0;
585+
}
586+
587+
bool BpCharGT(const void *l, const void *r, Oid collation) {
588+
const BpChar *lbpchar = *(const BpChar **)l;
589+
const BpChar *rbpchar = *(const BpChar **)r;
590+
591+
return VarstrCmp(VARDATA_ANY(lbpchar), BcTruelen(lbpchar), VARDATA_ANY(rbpchar), BcTruelen(rbpchar),
592+
collation) > 0;
593+
}
594+
549595
} // namespace textop
550596

551597
namespace numericop {
@@ -755,6 +801,16 @@ std::map<OperMinMaxKey, OperMinMaxFunc> min_max_opers = {
755801
INIT_MIN_MAX_OPER(TEXTOID, TEXTOID, BTGreaterStrategyNumber,
756802
textop::TextGT),
757803

804+
// oper(bpchar, bpchar)
805+
INIT_MIN_MAX_OPER(BPCHAROID, BPCHAROID, BTLessStrategyNumber, textop::BpCharLT),
806+
INIT_MIN_MAX_OPER(BPCHAROID, BPCHAROID, BTLessEqualStrategyNumber,
807+
textop::BpCharLE),
808+
INIT_MIN_MAX_OPER(BPCHAROID, BPCHAROID, BTEqualStrategyNumber, textop::BpCharEQ),
809+
INIT_MIN_MAX_OPER(BPCHAROID, BPCHAROID, BTGreaterEqualStrategyNumber,
810+
textop::BpCharGE),
811+
INIT_MIN_MAX_OPER(BPCHAROID, BPCHAROID, BTGreaterStrategyNumber,
812+
textop::BpCharGT),
813+
758814
// oper(numeric, numeric)
759815
INIT_MIN_MAX_OPER(NUMERICOID, NUMERICOID, BTLessStrategyNumber,
760816
numericop::NumericLT),

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern bool CharLE(const void *l, const void *r, Oid /*collation*/);
2323
extern bool CharEQ(const void *l, const void *r, Oid /*collation*/);
2424
extern bool CharGE(const void *l, const void *r, Oid /*collation*/);
2525
extern bool CharGT(const void *l, const void *r, Oid /*collation*/);
26+
2627
} // namespace charop
2728

2829
namespace int2op {
@@ -128,6 +129,13 @@ extern bool TextLE(const void *l, const void *r, Oid collation);
128129
extern bool TextEQ(const void *l, const void *r, Oid collation);
129130
extern bool TextGE(const void *l, const void *r, Oid collation);
130131
extern bool TextGT(const void *l, const void *r, Oid collation);
132+
133+
extern bool BpCharLT(const void *l, const void *r, Oid /*collation*/);
134+
extern bool BpCharLE(const void *l, const void *r, Oid /*collation*/);
135+
extern bool BpCharEQ(const void *l, const void *r, Oid /*collation*/);
136+
extern bool BpCharGE(const void *l, const void *r, Oid /*collation*/);
137+
extern bool BpCharGT(const void *l, const void *r, Oid /*collation*/);
138+
131139
} // namespace textop
132140

133141
namespace numericop {

contrib/pax_storage/src/cpp/storage/pax_filter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static bool CheckNonnullValue(const ::pax::stats::ColumnBasicInfo &minmax,
494494
break;
495495
}
496496
default:
497-
Assert(false);
497+
// not support others `sk_strategy`
498498
matches = BoolGetDatum(true);
499499
break;
500500
}

0 commit comments

Comments
 (0)