Implement Spark-compatible `log1p`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 80/100
Hướng nghiên cứu
Bắt đầu bằng việc đọc crates/spark/src/function/math/expm1.rs để biết mẫu Signature::exact(vec![Float64]), chú thích #[user_doc] và cách xử lý null, sau đó đăng ký hàm mới theo cùng cách. Triển khai ln_1p và ánh xạ mọi đầu vào <= -1.0 thành NULL, khớp với UnaryLogExpression của Spark. Bật và mở rộng các truy vấn giữ chỗ trong crates/sqllogictest/test_files/math/log1p.slt, sau đó chạy tệp slt đó. Hoàn tất nghĩa là các ca slt cho NULL, -1.0, -Infinity, NaN, Infinity, -0.0 và các giá trị rất nhỏ đều vượt qua và kết quả khớp với StrictMath.log1p.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Part of #174 and apache/datafusion-comet#7300.
What the function does
log1p(expr) returns ln(1 + expr), computed accurately for expr near 0. The argument is implicitly cast to DOUBLE (UnaryMathExpression, inputTypes = Seq(DoubleType)) and the result is DOUBLE. Like the other Hive-derived log functions (UnaryLogExpression), any input <= -1.0 returns NULL instead of -Infinity or NaN. The result is always nullable. Available since 1.4.0.
Spark evaluates java.lang.StrictMath.log1p (fdlibm) in both the interpreted and code-generated paths.
Examples
SELECT log1p(0);
-- 0.0
SELECT log1p(-1);
-- NULL
SELECT log1p(-2);
-- NULL
SELECT log1p(CAST('NaN' AS DOUBLE));
-- NaN
SELECT log1p(CAST('Infinity' AS DOUBLE));
-- Infinity
MathExpressionsSuite checks log1p against StrictMath.log1p for 0.0, 0.1, ..., 2.0 and expects NULL for -10.0, -9.0, ..., -1.0.
Edge cases to test
- NULL input.
- Exactly -1.0 returns NULL (the boundary is
<= yAsymptotewithyAsymptote = -1.0), and values just above it (e.g.-0.9999999999999999) return a large negative finite value. - Values below -1 (including
-Infinity) return NULL, not NaN. - NaN returns NaN (
NaN <= -1.0is false).+InfinityreturnsInfinity. -0.0returns-0.0and0.0returns0.0(check the sign).- Tiny values (
1e-300,1e-20) return the input value, which is whereln(1 + x)would lose precision. - Bit-exact results: Spark uses fdlibm via
StrictMath. Rust'sf64::ln_1pcalls the platformlog1p, which can differ in the last ulp on some inputs and platforms. Compare againstStrictMath.log1pvalues for a range of inputs (e.g. 0.1 to 2.0 and large values like1e300), or use a port of fdlibms_log1p.cif they differ. - Integer, DECIMAL, FLOAT and STRING arguments (cast to DOUBLE first; with ANSI on an invalid string fails in the cast).
Differences across Spark versions
None found (3.4 through 4.2; only contextIndependentFoldable was added).
Implementation notes
- Spark:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala,Log1p, base classesUnaryLogExpressionandUnaryMathExpression. - DataFusion core has no
log1p(it hasln,log,log2,log10). - Follow
crates/spark/src/function/math/expm1.rs(Signature::exact(vec![Float64]),exp_m1), usingln_1pand mappingx <= -1.0to NULL. - Tests: the placeholder
crates/sqllogictest/test_files/math/log1p.sltexists with a commented-out query; enable and extend it. Document with#[user_doc].
This issue was generated by an LLM (Claude) from the Apache Spark source code and tests. Examples come from Spark's ExpressionDescription examples, test suites and .sql.out golden files, but please verify them against Spark before relying on them.
- Ngôn ngữ chính
- Rust
- Star
- 7
- Fork
- 15
- Merge trung bình
- 16 giờ 43 phút
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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-spark
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
apache/datafusion-spark#287 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] make_dt_interval returns NULL for more than about 1.49 million days, Spark returns the intervalCó thể đã có người làm @Subodh-17 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/datafusion-spark#109 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 18/100
apache/datafusion-spark#299 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
apache/datafusion-spark#298 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
apache/datafusion-spark#297 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/datafusion-spark
Issue tương tự
-
comp-rbac
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ClickHouse/ClickHouse#131875 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesCó thể đã có người làm @Borg93 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
lance-format/lance#11117 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
storytold/photocraft#15232 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
forge: fork preflight reads still send `requireCanonical: false`, which Rootstock rejects (-32603)Có thể đã có người làm @Ynyesto đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
foundry-rs/foundry#18485 ·
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 70/100
bondybondbond/rushcut#238 · 1 bình luận ·