mkleen commented on code in PR #27064:
URL: https://github.com/apache/datafusion/pull/27064#discussion_r4590376520
##########
datafusion/functions-aggregate/src/approx_distinct.rs:
##########
@@ -913,75 +926,69 @@ fn is_fixed_domain_type(data_type: &DataType) -> bool {
)
}
+/// Returns true if `approx_distinct` can run on this data type
fn is_supported_type(data_type: &DataType) -> bool {
- let value_type = encoded_value_type(data_type);
- matches!(value_type, DataType::Null)
- || is_fixed_domain_type(value_type)
- || is_hll_groups_type(value_type)
-}
+ if has_float_leaf(data_type) {
Review Comment:
Nit: `has_float_leaf` already recurses into dictionary/REE values, so it
only needs to run once. Splitting the encoding unwrap into a helper avoids
re-walking the type at each nesting level:
```rust
/// Returns true if `approx_distinct` can run on this data type
fn is_supported_type(data_type: &DataType) -> bool {
// Floats are rejected at any depth, including inside containers
// and dictionary or run-end-encoded values
!has_float_leaf(data_type) && is_supported_value_type(data_type)
}
/// Checks the outer type only, after looking through dictionary and
/// run-end encoding. The caller has already rejected float leaves.
fn is_supported_value_type(data_type: &DataType) -> bool {
match data_type {
DataType::Dictionary(_, values) => is_supported_value_type(values),
DataType::RunEndEncoded(_, values) =>
is_supported_value_type(values.data_type()),
DataType::Null
| DataType::Boolean
// ... same list as now ...
| DataType::Union(_, _) => true,
_ => false,
}
}
```
Not a blocker, feel free to ignore.
--
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]