jiaqizho commented on code in PR #1192: URL: https://github.com/apache/cloudberry/pull/1192#discussion_r2272224114
########## src/backend/gporca/libgpopt/src/operators/CPhysicalAgg.cpp: ########## @@ -293,11 +292,65 @@ CDistributionSpec * CPhysicalAgg::PdsMaximalHashed(CMemoryPool *mp, CColRefArray *colref_array) { GPOS_ASSERT(nullptr != colref_array); + CColRefArray *pcraResHashs = nullptr; + + if (GPOS_FTRACE(EopttraceAggRRSFirstKey)) { + pcraResHashs = GPOS_NEW(mp) CColRefArray(mp); + if (colref_array->Size() > 0) { + CColRef *colref = (*colref_array)[0]; + pcraResHashs->Append(colref); + } + } else if (GPOS_FTRACE(EopttraceAggRRSMinimalLenKey)) { + ULONG ulsz = colref_array->Size(); + pcraResHashs = GPOS_NEW(mp) CColRefArray(mp); + + LINT minimal_typlen = gpos::lint_max; // less than minimal typlen + LINT minimal_typlen_ul = -1; + for (ULONG ul = 0; ul < ulsz; ul++) { + CColRef *pcr =(*colref_array)[ul]; + const gpmd::IMDType *pmdtyp = pcr->RetrieveType(); + LINT typlen = pmdtyp->IsFixedLength() ? pmdtyp->Length() : (gpos::lint_max - 1); + + if (typlen < minimal_typlen) { + minimal_typlen = typlen; + minimal_typlen_ul = ul; + } + } + + if (minimal_typlen_ul != -1) { Review Comment: `minimal_typlen_ul` will be `-1` if current `colref_array` is empty. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cloudberry.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cloudberry.apache.org For additional commands, e-mail: commits-h...@cloudberry.apache.org