Native timestamp casts fail or panic for years beyond chrono's range
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 56/100
Hướng nghiên cứu
Start with pre_timestamp_cast and the timestamp conversion functions in native/spark-expr/src/utils.rs, then inspect date-to-timestamp handling in native/spark-expr/src/conversion_funcs/temporal.rs and test_cast_unsupported_timestamp_to_date in conversion_funcs/cast.rs. Reproduce with the SQL cases in spark/src/test/resources/sql-tests/... under the default Spark 4.1 profile. Done means out-of-range values return Spark-compatible results through fallback, including TRY casts, without native errors or panics.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Native casts to and from timestamps fail for values whose year is outside chrono's range (about ±262,143), while Spark supports timestamps up to year 294,247 and returns a result. This happens for TRY casts too, so try_cast raises instead of returning a value.
| Query | Comet |
|---|---|
CAST(ts AS DATE) |
CometNativeException: Cast error: Cannot convert TimestampMicrosecondType 9000000000000000000 to datetime. Comet only supports dates between Jan 1, 262145 BCE and Dec 31, 262143 CE |
CAST(ts AS STRING) |
same error |
try_cast(ts AS DATE) |
same error |
CAST(dt AS TIMESTAMP) |
native panic at spark-expr/src/conversion_funcs/temporal.rs:74:34 |
Steps to reproduce
As a SQL file test (spark/src/test/resources/sql-tests/...), default Spark 4.1 profile:
statement
CREATE TABLE tsr(ts timestamp, dt date) USING parquet
statement
INSERT INTO tsr VALUES
(timestamp_micros(9000000000000000000), date_from_unix_date(100000000)),
(timestamp_micros(0), date_from_unix_date(0))
query
SELECT CAST(ts AS DATE) FROM tsr
query
SELECT CAST(ts AS STRING) FROM tsr
query
SELECT try_cast(ts AS DATE) FROM tsr
query
SELECT CAST(dt AS TIMESTAMP) FROM tsr
timestamp_micros(9000000000000000000) is in year 287,000 or so, and date_from_unix_date(100000000) in year 275,000 or so; both are valid Spark values.
Expected behavior
The same results as Spark. Where the native kernel cannot represent the value, the serde should fall back to Spark rather than fail or panic.
Additional context
The error paths:
pre_timestamp_castinnative/spark-expr/src/utils.rs(as_datetime(...).ok_or_else(datetime_cast_err)), used by timestamp to string and timestamp to date for every eval mode.timestamp_ntz_to_timestampandcast_timestamp_to_ntzin the same file, same pattern.- Date to timestamp in
native/spark-expr/src/conversion_funcs/temporal.rs:epoch + chrono::Duration::days(d)panics. The comment above it says chrono's range covers everyi32day count, but it does not. test_cast_unsupported_timestamp_to_dateinconversion_funcs/cast.rsasserts the error fori64::MAX.
Found while auditing which expressions can safely run as TopK later keys in https://github.com/apache/datafusion-comet/pull/7457 , which now treats every timestamp cast as able to fail. Suggested triage: priority:high (native panic), area:expressions.
- Ngôn ngữ chính
- Scala
- Star
- 1.3k
- Fork
- 414
- Merge trung bình
- 3 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 210
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/datafusion-comet
-
requires-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/datafusion-comet#7583 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
apache/datafusion-comet#7559 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area:writer bug priority:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/datafusion-comet#7558 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/datafusion-comet#7557 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`rand` and `randn` with an integer seed fall back to Spark without a fallback reasonCó thể đã có người làm @galaxytemple đã nhận 3 ngày trước. Đang mởrequires-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/datafusion-comet#7479 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của apache/datafusion-comet
Issue tương tự
-
A-api C-bug S-ready-for-human
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
ergoplatform/ergo#2932 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
lichess-org/lila#22454 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
chipsalliance/rocket-chip#3845 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 13 ngày