Jefffrey commented on code in PR #22564:
URL: https://github.com/apache/datafusion/pull/22564#discussion_r3354693153
##########
datafusion/functions/src/math/log.rs:
##########
@@ -71,6 +66,11 @@ impl Default for LogFunc {
impl LogFunc {
pub fn new() -> Self {
+ let as_decimal = Coercion::new_implicit(
Review Comment:
sorry why is this change being made now? we're now casting integers to
decimal?
##########
datafusion/functions/src/math/log.rs:
##########
@@ -106,58 +101,158 @@ fn is_valid_integer_base(base: f64) -> bool {
base.trunc() == base && base >= 2.0 && base <= u32::MAX as f64
}
+#[inline]
+fn exact_integer_base(base: f64) -> Option<u32> {
+ is_valid_integer_base(base).then_some(base as u32)
+}
+
+#[inline]
+fn exact_integer_log(value: u128, base: u32) -> Option<u32> {
+ if value == 0 {
+ return None;
+ }
+
+ let base_u128 = u128::from(base);
+ let int_log = value.ilog(base_u128);
+ (base_u128.checked_pow(int_log) == Some(value)).then_some(int_log)
+}
+
+#[inline]
+fn exact_positive_u128_from_float<T: Float + ToPrimitive>(value: T) ->
Option<u128> {
+ let value_u128 = value.to_u128()?;
+ if value_u128 == 0 {
+ return None;
+ }
+
+ let exact_value = T::from(value_u128)?;
+ (value == exact_value).then_some(value_u128)
+}
Review Comment:
same goes here, why are these changes being made here now?
--
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]