Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ suffixes (e.g. `Europe/Moscow`), and the full Spark timestamp year range
(-290308 to 294247). Note that `CAST(string AS DATE)` is only compatible for years between
262143 BC and 262142 AD due to an underlying library limitation.

## String to TimestampNTZ

Comet's native `CAST(string AS TIMESTAMP_NTZ)` implementation matches Apache Spark's behavior.
Unlike `CAST(string AS TIMESTAMP)`, this cast is timezone-independent: any timezone offset in
the input string (e.g. `+08:00`, `Z`, `UTC`) is silently discarded, and the local date-time
components are preserved as-is. Time-only strings (e.g. `T12:34:56`, `12:34`) produce `NULL`.
The result is always a wall-clock timestamp with no timezone conversion or DST adjustment.

## Decimal with Negative Scale to String

Casting a `DecimalType` with a negative scale to `StringType` is marked as incompatible when
Expand Down
6 changes: 5 additions & 1 deletion native/spark-expr/src/conversion_funcs/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ use crate::conversion_funcs::numeric::{
};
use crate::conversion_funcs::string::{
cast_string_to_date, cast_string_to_decimal, cast_string_to_float, cast_string_to_int,
cast_string_to_timestamp, is_df_cast_from_string_spark_compatible, spark_cast_utf8_to_boolean,
cast_string_to_timestamp, cast_string_to_timestamp_ntz,
is_df_cast_from_string_spark_compatible, spark_cast_utf8_to_boolean,
};
use crate::conversion_funcs::temporal::{
cast_date_to_timestamp, is_df_cast_from_date_spark_compatible,
Expand Down Expand Up @@ -316,6 +317,9 @@ pub(crate) fn cast_array(
(Null, _) => Ok(cast_with_options(&array, to_type, &native_cast_options)?),
(Utf8, Boolean) => spark_cast_utf8_to_boolean::<i32>(&array, eval_mode),
(LargeUtf8, Boolean) => spark_cast_utf8_to_boolean::<i64>(&array, eval_mode),
(Utf8, Timestamp(_, None)) => {
cast_string_to_timestamp_ntz(&array, eval_mode, true, cast_options.is_spark4_plus)
}
(Utf8, Timestamp(_, _)) => cast_string_to_timestamp(
&array,
to_type,
Expand Down
Loading
Loading