Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rust/arrow/src/array/array_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def_numeric_from_vec!(TimestampMicrosecondType);

impl<T: ArrowTimestampType> PrimitiveArray<T> {
/// Construct a timestamp array from a vec of i64 values and an optional timezone
pub fn from_vec(data: Vec<i64>, timezone: Option<Arc<String>>) -> Self {
pub fn from_vec(data: Vec<i64>, timezone: Option<String>) -> Self {
let array_data =
ArrayData::builder(DataType::Timestamp(T::get_time_unit(), timezone))
.len(data.len())
Expand All @@ -393,7 +393,7 @@ impl<T: ArrowTimestampType> PrimitiveArray<T> {

impl<T: ArrowTimestampType> PrimitiveArray<T> {
/// Construct a timestamp array from a vec of Option<i64> values and an optional timezone
pub fn from_opt_vec(data: Vec<Option<i64>>, timezone: Option<Arc<String>>) -> Self {
pub fn from_opt_vec(data: Vec<Option<i64>>, timezone: Option<String>) -> Self {
// TODO: duplicated from def_numeric_from_vec! macro, it looks possible to convert to generic
let data_len = data.len();
let mut null_buf = MutableBuffer::new_null(data_len);
Expand Down
8 changes: 4 additions & 4 deletions rust/arrow/src/compute/kernels/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ mod tests {
fn test_cast_timestamp_to_date32() {
let a = TimestampMillisecondArray::from_opt_vec(
vec![Some(864000000005), Some(1545696000001), None],
Some(Arc::new(String::from("UTC"))),
Some(String::from("UTC")),
);
let array = Arc::new(a) as ArrayRef;
let b = cast(&array, &DataType::Date32(DateUnit::Day)).unwrap();
Expand Down Expand Up @@ -1551,7 +1551,7 @@ mod tests {
fn test_cast_timestamp_to_i64() {
let a = TimestampMillisecondArray::from_opt_vec(
vec![Some(864000000005), Some(1545696000001), None],
Some(Arc::new("UTC".to_string())),
Some("UTC".to_string()),
);
let array = Arc::new(a) as ArrayRef;
let b = cast(&array, &DataType::Int64).unwrap();
Expand Down Expand Up @@ -2815,7 +2815,7 @@ mod tests {

/// Create instances of arrays with varying types for cast tests
fn get_arrays_of_all_types() -> Vec<ArrayRef> {
let tz_name = Arc::new(String::from("America/New_York"));
let tz_name = String::from("America/New_York");
let binary_data: Vec<&[u8]> = vec![b"foo", b"bar"];
vec![
Arc::new(BinaryArray::from(binary_data.clone())),
Expand Down Expand Up @@ -3008,7 +3008,7 @@ mod tests {
// Get a selection of datatypes to try and cast to
fn get_all_types() -> Vec<DataType> {
use DataType::*;
let tz_name = Arc::new(String::from("America/New_York"));
let tz_name = String::from("America/New_York");

vec![
Null,
Expand Down
11 changes: 4 additions & 7 deletions rust/arrow/src/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub enum DataType {
/// * As used in the Olson time zone database (the "tz database" or
/// "tzdata"), such as "America/New_York"
/// * An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30
Timestamp(TimeUnit, Option<Arc<String>>),
Timestamp(TimeUnit, Option<String>),
/// A 32-bit date representing the elapsed time since UNIX epoch (1970-01-01)
/// in days (32 bits).
Date32(DateUnit),
Expand Down Expand Up @@ -994,7 +994,7 @@ impl DataType {
};
let tz = match map.get("timezone") {
None => Ok(None),
Some(VString(tz)) => Ok(Some(Arc::new(tz.to_string()))),
Some(VString(tz)) => Ok(Some(tz.clone())),
_ => Err(ArrowError::ParseError(
"timezone must be a string".to_string(),
)),
Expand Down Expand Up @@ -2068,17 +2068,14 @@ mod tests {
Field::new("c15", DataType::Timestamp(TimeUnit::Second, None), false),
Field::new(
"c16",
DataType::Timestamp(
TimeUnit::Millisecond,
Some(Arc::new("UTC".to_string())),
),
DataType::Timestamp(TimeUnit::Millisecond, Some("UTC".to_string())),
false,
),
Field::new(
"c17",
DataType::Timestamp(
TimeUnit::Microsecond,
Some(Arc::new("Africa/Johannesburg".to_string())),
Some("Africa/Johannesburg".to_string()),
),
false,
),
Expand Down
8 changes: 3 additions & 5 deletions rust/arrow/src/ipc/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use flatbuffers::{
FlatBufferBuilder, ForwardsUOffset, UnionWIPOffset, Vector, WIPOffset,
};
use std::collections::HashMap;
use std::sync::Arc;

use DataType::*;

Expand Down Expand Up @@ -211,8 +210,7 @@ pub(crate) fn get_data_type(field: ipc::Field, may_be_dictionary: bool) -> DataT
}
ipc::Type::Timestamp => {
let timestamp = field.type_as_timestamp().unwrap();
let timezone: Option<Arc<String>> =
timestamp.timezone().map(|tz| Arc::new(tz.to_string()));
let timezone: Option<String> = timestamp.timezone().map(|tz| tz.to_string());
match timestamp.unit() {
ipc::TimeUnit::SECOND => DataType::Timestamp(TimeUnit::Second, timezone),
ipc::TimeUnit::MILLISECOND => {
Expand Down Expand Up @@ -471,7 +469,7 @@ pub(crate) fn get_fb_field_type<'a>(
}
}
Timestamp(unit, tz) => {
let tz = tz.clone().unwrap_or_else(|| Arc::new(String::new()));
let tz = tz.clone().unwrap_or_else(String::new);
let tz_str = fbb.create_string(tz.as_str());
let mut builder = ipc::TimestampBuilder::new(fbb);
let time_unit = match unit {
Expand Down Expand Up @@ -672,7 +670,7 @@ mod tests {
"timestamp[us]",
DataType::Timestamp(
TimeUnit::Microsecond,
Some(Arc::new("Africa/Johannesburg".to_string())),
Some("Africa/Johannesburg".to_string()),
),
false,
),
Expand Down
8 changes: 4 additions & 4 deletions rust/arrow/src/util/integration_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,10 @@ mod tests {

#[test]
fn test_arrow_data_equality() {
let secs_tz = Some(Arc::new("Europe/Budapest".to_string()));
let millis_tz = Some(Arc::new("America/New_York".to_string()));
let micros_tz = Some(Arc::new("UTC".to_string()));
let nanos_tz = Some(Arc::new("Africa/Johannesburg".to_string()));
let secs_tz = Some("Europe/Budapest".to_string());
let millis_tz = Some("America/New_York".to_string());
let micros_tz = Some("UTC".to_string());
let nanos_tz = Some("Africa/Johannesburg".to_string());
let schema = Schema::new(vec![
Field::new("bools", DataType::Boolean, true),
Field::new("int8s", DataType::Int8, true),
Expand Down
7 changes: 2 additions & 5 deletions rust/parquet/src/arrow/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,17 +1475,14 @@ mod tests {
Field::new("c15", DataType::Timestamp(TimeUnit::Second, None), false),
Field::new(
"c16",
DataType::Timestamp(
TimeUnit::Millisecond,
Some(Arc::new("UTC".to_string())),
),
DataType::Timestamp(TimeUnit::Millisecond, Some("UTC".to_string())),
false,
),
Field::new(
"c17",
DataType::Timestamp(
TimeUnit::Microsecond,
Some(Arc::new("Africa/Johannesburg".to_string())),
Some("Africa/Johannesburg".to_string()),
),
false,
),
Expand Down