Returns None if the value can't be converted to i256. Modified from
(v: &BigInt)
| 342 | /// Returns None if the value can't be converted to i256. |
| 343 | /// Modified from <https://github.com/apache/arrow-rs/blob/c4dbf0d8af6ca5a19b8b2ea777da3c276807fc5e/arrow-buffer/src/bigint/mod.rs#L303> |
| 344 | fn bigint_to_i256(v: &BigInt) -> Option<i256> { |
| 345 | let v_bytes = v.to_signed_bytes_le(); |
| 346 | match v_bytes.len().cmp(&32) { |
| 347 | Ordering::Less => { |
| 348 | let mut bytes = if v.is_negative() { |
| 349 | [255_u8; 32] |
| 350 | } else { |
| 351 | [0; 32] |
| 352 | }; |
| 353 | bytes[0..v_bytes.len()].copy_from_slice(&v_bytes[..v_bytes.len()]); |
| 354 | Some(i256::from_le_bytes(bytes)) |
| 355 | } |
| 356 | Ordering::Equal => Some(i256::from_le_bytes(v_bytes.try_into().unwrap())), |
| 357 | Ordering::Greater => None, |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | fn parse_decimal(unsigned_number: &str, negative: bool) -> Result<Expr> { |
| 362 | let mut dec = BigDecimal::from_str(unsigned_number).map_err(|e| { |
searching dependent graphs…