subhramit commented on code in PR #24541:
URL: https://github.com/apache/datafusion/pull/24541#discussion_r3827908696


##########
datafusion/common/src/config.rs:
##########
@@ -748,6 +748,94 @@ impl Display for ConfigMinTwoUsize {
     }
 }
 
+/// A `u8` configuration value that rejects values greater than 100 when set
+/// from strings.
+///
+/// Use this for options that represent a percentage, such as
+/// [`OptimizerOptions::default_filter_selectivity`]. Without this, an
+/// out-of-range value (e.g. 200) is silently accepted at `SET` time and only
+/// rejected later, when the value is actually consumed (e.g. by
+/// `FilterExec`).
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
+pub struct ConfigFilterSelectivity(u8);

Review Comment:
   I took the opportunity and refactored in this PR itself in 
https://github.com/apache/datafusion/pull/24541/commits/060041cc4fbe88598778af4ada0c66d0624b209b
 (also added a `value` field since we need to store the configured value as 
well). Have reused it in both existing typed `usize` wrappers 
(`ConfigNonZeroUsize` and `ConfigMinTwoUsize`). 
   However I did not reuse it here, as `default_filter_selectivity` appears to 
be the only config option currently modeled as an integer percentage in 
`0..=100` due to which `ConfigFilterSelectivity` is `u8` , and that would 
require widening to `usize` and narrowing back to `u8`. A broader abstraction 
for it (currently) wouldn't make sense with just one use site.
   See if this is what we are looking for.



-- 
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]

Reply via email to