MCPcopy Create free account
hub / github.com/apache/arrow-rs / build_timestamp_array_impl

Function build_timestamp_array_impl

arrow-csv/src/reader/mod.rs:1030–1067  ·  view source on GitHub ↗
(
    line_number: usize,
    rows: &StringRecords<'_>,
    col_idx: usize,
    timezone: &Tz,
    null_regex: &NullRegex,
)

Source from the content-addressed store, hash-verified

1028}
1029
1030fn build_timestamp_array_impl<T: ArrowTimestampType, Tz: TimeZone>(
1031 line_number: usize,
1032 rows: &StringRecords<'_>,
1033 col_idx: usize,
1034 timezone: &Tz,
1035 null_regex: &NullRegex,
1036) -> Result<PrimitiveArray<T>, ArrowError> {
1037 rows.iter()
1038 .enumerate()
1039 .map(|(row_index, row)| {
1040 let s = row.get(col_idx);
1041 if null_regex.is_null(s) {
1042 return Ok(None);
1043 }
1044
1045 let date = string_to_datetime(timezone, s)
1046 .and_then(|date| match T::UNIT {
1047 TimeUnit::Second => Ok(date.timestamp()),
1048 TimeUnit::Millisecond => Ok(date.timestamp_millis()),
1049 TimeUnit::Microsecond => Ok(date.timestamp_micros()),
1050 TimeUnit::Nanosecond => date.timestamp_nanos_opt().ok_or_else(|| {
1051 ArrowError::ParseError(format!(
1052 "{} would overflow 64-bit signed nanoseconds",
1053 date.to_rfc3339(),
1054 ))
1055 }),
1056 })
1057 .map_err(|e| {
1058 ArrowError::ParseError(format!(
1059 "Error parsing column {col_idx} at line {}: {}",
1060 line_number + row_index,
1061 e
1062 ))
1063 })?;
1064 Ok(Some(date))
1065 })
1066 .collect()
1067}
1068
1069// parses a specific column (col_idx) into an Arrow Array.
1070fn build_boolean_array(

Callers

nothing calls this directly

Calls 7

string_to_datetimeFunction · 0.85
collectMethod · 0.80
and_thenMethod · 0.80
timestampMethod · 0.80
iterMethod · 0.45
getMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected