Convert a Value to a comparable representation for equality/uniqueness checks This handles the complexity of comparing different Value types consistently
(value: &Value)
| 241 | /// Convert a Value to a comparable representation for equality/uniqueness checks |
| 242 | /// This handles the complexity of comparing different Value types consistently |
| 243 | fn value_to_comparable(value: &Value) -> FunctionResult<ComparableValue> { |
| 244 | match value { |
| 245 | Value::Boolean(b) => Ok(ComparableValue::Boolean(*b)), |
| 246 | Value::Number(n) => Ok(ComparableValue::Number(n.to_bits())), // Use bit representation for exact floating point comparison |
| 247 | Value::String(s) => Ok(ComparableValue::String(s.clone())), |
| 248 | Value::DateTime(dt) => Ok(ComparableValue::DateTime(dt.timestamp())), |
| 249 | Value::DateTimeWithFixedOffset(dt) => Ok(ComparableValue::DateTime(dt.timestamp())), |
| 250 | Value::DateTimeWithNamedTz(_, dt) => Ok(ComparableValue::DateTime(dt.timestamp())), |
| 251 | Value::TimeWindow(tw) => Ok(ComparableValue::String(format!("{:?}", tw))), // Use debug format for comparison |
| 252 | // Add more value types as needed |
| 253 | _ => { |
| 254 | warn!("Unsupported value type for comparison: {:?}", value); |
| 255 | Err(FunctionError::InvalidArgumentType { |
| 256 | message: format!("Value type {:?} is not supported for comparison", value), |
| 257 | }) |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /// Comparable representation of values for equality and uniqueness checks |
| 263 | /// This ensures consistent comparison across different value types |
no test coverage detected