Returns the minimum value for the given numeric `DataType`. This function returns the smallest representable value for numeric and temporal data types. For non-numeric types, it returns `None`. # Supported Types - **Integer types**: `i8::MIN`, `i16::MIN`, etc. - **Unsigned types**: Always 0 (`u8::MIN`, `u16::MIN`, etc.) - **Float types**: Negative infinity (IEEE 754) - **Decimal types**: Smalle
(datatype: &DataType)
| 4908 | /// - **Time types**: 0 (midnight) |
| 4909 | /// - **Duration types**: `i64::MIN` |
| 4910 | pub fn min(datatype: &DataType) -> Option<ScalarValue> { |
| 4911 | match datatype { |
| 4912 | DataType::Int8 => Some(ScalarValue::Int8(Some(i8::MIN))), |
| 4913 | DataType::Int16 => Some(ScalarValue::Int16(Some(i16::MIN))), |
| 4914 | DataType::Int32 => Some(ScalarValue::Int32(Some(i32::MIN))), |
| 4915 | DataType::Int64 => Some(ScalarValue::Int64(Some(i64::MIN))), |
| 4916 | DataType::UInt8 => Some(ScalarValue::UInt8(Some(u8::MIN))), |
| 4917 | DataType::UInt16 => Some(ScalarValue::UInt16(Some(u16::MIN))), |
| 4918 | DataType::UInt32 => Some(ScalarValue::UInt32(Some(u32::MIN))), |
| 4919 | DataType::UInt64 => Some(ScalarValue::UInt64(Some(u64::MIN))), |
| 4920 | DataType::Float16 => Some(ScalarValue::Float16(Some(f16::NEG_INFINITY))), |
| 4921 | DataType::Float32 => Some(ScalarValue::Float32(Some(f32::NEG_INFINITY))), |
| 4922 | DataType::Float64 => Some(ScalarValue::Float64(Some(f64::NEG_INFINITY))), |
| 4923 | DataType::Decimal128(precision, scale) => { |
| 4924 | // For decimal, min is -10^(precision-scale) + 10^(-scale) |
| 4925 | // But for simplicity, we use the minimum i128 value that fits the precision |
| 4926 | let max_digits = 10_i128.pow(*precision as u32) - 1; |
| 4927 | Some(ScalarValue::Decimal128( |
| 4928 | Some(-max_digits), |
| 4929 | *precision, |
| 4930 | *scale, |
| 4931 | )) |
| 4932 | } |
| 4933 | DataType::Decimal256(precision, scale) => { |
| 4934 | // Similar to Decimal128 but with i256 |
| 4935 | // For now, use a large negative value |
| 4936 | let max_digits = i256::from_i128(10_i128) |
| 4937 | .checked_pow(*precision as u32) |
| 4938 | .and_then(|v| v.checked_sub(i256::from_i128(1))) |
| 4939 | .unwrap_or(i256::MAX); |
| 4940 | Some(ScalarValue::Decimal256( |
| 4941 | Some(max_digits.neg_wrapping()), |
| 4942 | *precision, |
| 4943 | *scale, |
| 4944 | )) |
| 4945 | } |
| 4946 | DataType::Date32 => Some(ScalarValue::Date32(Some(i32::MIN))), |
| 4947 | DataType::Date64 => Some(ScalarValue::Date64(Some(i64::MIN))), |
| 4948 | DataType::Time32(TimeUnit::Second) => { |
| 4949 | Some(ScalarValue::Time32Second(Some(0))) |
| 4950 | } |
| 4951 | DataType::Time32(TimeUnit::Millisecond) => { |
| 4952 | Some(ScalarValue::Time32Millisecond(Some(0))) |
| 4953 | } |
| 4954 | DataType::Time64(TimeUnit::Microsecond) => { |
| 4955 | Some(ScalarValue::Time64Microsecond(Some(0))) |
| 4956 | } |
| 4957 | DataType::Time64(TimeUnit::Nanosecond) => { |
| 4958 | Some(ScalarValue::Time64Nanosecond(Some(0))) |
| 4959 | } |
| 4960 | DataType::Timestamp(unit, tz) => match unit { |
| 4961 | TimeUnit::Second => { |
| 4962 | Some(ScalarValue::TimestampSecond(Some(i64::MIN), tz.clone())) |
| 4963 | } |
| 4964 | TimeUnit::Millisecond => Some(ScalarValue::TimestampMillisecond( |
| 4965 | Some(i64::MIN), |
| 4966 | tz.clone(), |
| 4967 | )), |
no test coverage detected