read_side_padding ignores the pad string for dictionary inputs in lpad and rpad

Đang mở Phù hợp với người mới
#7,453 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust, spark
Lĩnh vực
backend

Hướng nghiên cứu

Lỗi nằm trong native/spark-expr/src/static_invoke/char_varchar_utils/read_side_padding.rs, ở nhánh ba tham số xử lý đầu vào Dictionary: cả hai nhánh Dictionary đều truyền SPACE, trong khi nhánh Utf8 và LargeUtf8 truyền chuỗi đệm. Hãy đọc nhánh đó trước, rồi thêm một unit test với đầu vào Dictionary và chuỗi đệm khác khoảng trắng, chẳng hạn "x", với kết quả mong đợi là ["abxxx", "abxxx"]. Công việc hoàn tất khi kết quả Dictionary khớp với kết quả Utf8 cho cùng đầu vào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

requires-triage
Describe the bug

In read_side_padding.rs, the three-argument arm ([Array, Scalar(Int32), Scalar(Utf8)]) ignores the pad string when the input is a dictionary array. The Utf8 and LargeUtf8 branches pass string to spark_read_side_padding_internal, but both Dictionary branches pass SPACE. So rpad/lpad with a custom pad pads with spaces instead.

https://github.com/apache/datafusion-comet/blob/644a8708839270d382a78715fca7e2b724143588/native/spark-expr/src/static_invoke/char_varchar_utils/read_side_padding.rs#L115-L132

Steps to reproduce

Kernel-level, on main at 644a87088:

let dict: DictionaryArray<Int32Type> = vec!["ab", "ab"].into_iter().collect();
let args = vec![
    ColumnarValue::Array(Arc::new(dict)),
    ColumnarValue::Scalar(ScalarValue::Int32(Some(5))),
    ColumnarValue::Scalar(ScalarValue::Utf8(Some("x".to_string()))),
];
spark_rpad(&args) // ["ab   ", "ab   "]

I couldn't find a SQL query that reaches this today. The native scan input unpacks dictionary-encoded strings (see test_unpack_dictionary_string in planner.rs), and the existing string_rpad.sql tests with a custom pad pass. So this looks latent, but it would give silent wrong results if a dictionary array ever reaches the kernel, which is what the Dictionary arm (added for SPARK-48498) is there for.

Expected behavior

["abxxx", "abxxx"], the same as for a Utf8 input.

Additional context

Found while reviewing my change for #7245 (PR #7450). The fix is to pass string instead of SPACE in the two Dictionary branches and add a unit test with a dictionary input and a non-space pad.

Willingness to contribute

I can contribute a fix for this bug independently

AI disclosure: this issue was investigated and written with an AI coding assistant, and reviewed by me.

Ngôn ngữ chính
Scala
Star
1.3k
Fork
405
Merge trung bình
3 ngày 7 giờ
Pull request đã merge (30 ngày)
225

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/datafusion-comet

Tất cả issue của apache/datafusion-comet

Issue tương tự

Thêm issue về Scala

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.