haohuaijin commented on code in PR #19285:
URL: https://github.com/apache/datafusion/pull/19285#discussion_r2616169881
##########
datafusion/physical-plan/src/aggregates/topk/heap.rs:
##########
@@ -451,23 +572,46 @@ compare_integer!(u8, u16, u32, u64);
compare_integer!(IntervalDayTime, IntervalMonthDayNano);
compare_float!(f16, f32, f64);
+/// Returns true if the given data type can be stored in a top-K aggregation
heap.
+///
+/// Supported types include Arrow primitives (integers, floats, decimals,
intervals)
+/// and UTF-8 strings (`Utf8`, `LargeUtf8`, `Utf8View`). This is used
internally by
+/// `PriorityMap::supports()` to validate aggregate value type compatibility.
+pub fn is_supported_heap_type(vt: &DataType) -> bool {
+ vt.is_primitive()
+ || matches!(
+ vt,
+ DataType::Utf8 | DataType::Utf8View | DataType::LargeUtf8
+ )
+}
+
pub fn new_heap(
limit: usize,
desc: bool,
vt: DataType,
) -> Result<Box<dyn ArrowHeap + Send>> {
+ if matches!(
+ vt,
+ DataType::Utf8 | DataType::LargeUtf8 | DataType::Utf8View
+ ) {
+ return Ok(Box::new(StringHeap::new(limit, desc, vt)));
+ }
+
macro_rules! downcast_helper {
($vt:ty, $d:ident) => {
return Ok(Box::new(PrimitiveHeap::<$vt>::new(limit, desc, vt)))
};
}
+ let vt_clone = vt.clone();
Review Comment:
look like this clone do not need
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]