Skip to content

Commit

Permalink
Merge pull request #1 from andygrove/fix-tests-spark-cast-options
Browse files Browse the repository at this point in the history
  • Loading branch information
parthchandra committed Dec 13, 2024
1 parent a7fad04 commit 1f3a3ee
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions native/spark-expr/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ impl SparkCastOptions {
eval_mode,
timezone: timezone.to_string(),
allow_incompat,
is_adapting_schema: false,
is_adapting_schema: false
}
}

Expand All @@ -583,6 +583,7 @@ impl SparkCastOptions {
is_adapting_schema: false,
}
}

}

/// Spark-compatible cast implementation. Defers to DataFusion's cast where that is known
Expand Down Expand Up @@ -2087,7 +2088,7 @@ mod tests {

let timezone = "UTC".to_string();
// test casting string dictionary array to timestamp array
let cast_options = SparkCastOptions::new(EvalMode::Legacy, timezone.clone(), false);
let cast_options = SparkCastOptions::new(EvalMode::Legacy, &timezone, false);
let result = cast_array(
dict_array,
&DataType::Timestamp(TimeUnit::Microsecond, Some(timezone.clone().into())),
Expand Down Expand Up @@ -2296,7 +2297,7 @@ mod tests {
fn test_cast_unsupported_timestamp_to_date() {
// Since datafusion uses chrono::Datetime internally not all dates representable by TimestampMicrosecondType are supported
let timestamps: PrimitiveArray<TimestampMicrosecondType> = vec![i64::MAX].into();
let cast_options = SparkCastOptions::new(EvalMode::Legacy, "UTC".to_string(), false);
let cast_options = SparkCastOptions::new(EvalMode::Legacy, "UTC", false);
let result = cast_array(
Arc::new(timestamps.with_timezone("Europe/Copenhagen")),
&DataType::Date32,
Expand All @@ -2309,7 +2310,7 @@ mod tests {
fn test_cast_invalid_timezone() {
let timestamps: PrimitiveArray<TimestampMicrosecondType> = vec![i64::MAX].into();
let cast_options =
SparkCastOptions::new(EvalMode::Legacy, "Not a valid timezone".to_string(), false);
SparkCastOptions::new(EvalMode::Legacy, "Not a valid timezone", false);
let result = cast_array(
Arc::new(timestamps.with_timezone("Europe/Copenhagen")),
&DataType::Date32,
Expand All @@ -2335,7 +2336,7 @@ mod tests {
let string_array = cast_array(
c,
&DataType::Utf8,
&SparkCastOptions::new(EvalMode::Legacy, "UTC".to_owned(), false),
&SparkCastOptions::new(EvalMode::Legacy, "UTC", false),
)
.unwrap();
let string_array = string_array.as_string::<i32>();
Expand Down Expand Up @@ -2400,10 +2401,9 @@ mod tests {
let cast_array = spark_cast(
ColumnarValue::Array(c),
&DataType::Struct(fields),
EvalMode::Legacy,
&SparkCastOptions::new(EvalMode::Legacy,
"UTC",
false,
false,
false)
)
.unwrap();
if let ColumnarValue::Array(cast_array) = cast_array {
Expand Down

0 comments on commit 1f3a3ee

Please sign in to comment.