Casting to a struct type with repeated field names fails with "ArrowArray struct has 2 children (expected 1)"
Maintainer thường phản hồi trong vòng 1 ngà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
- 68/100
Hướng nghiên cứu
Đọc nhánh struct của CometCast.isSupported và so sánh nó với CometCreateNamedStruct, thứ đã từ chối các tên trường lặp lại; các nhánh array và map đệ quy vào nó, vì vậy một kiểm tra bao phủ các trường hợp lồng nhau trong SQL repro. Tái hiện với ba truy vấn CAST thất bại cộng với hai đối chứng thành công, sau đó xác nhận bản sửa khiến cast fallback để kết quả khớp với Spark. Hoàn thành trông giống như một case mới bao phủ các tên trường struct lặp lại trong bộ kiểm thử cast và không có IllegalStateException từ NativeUtil.importVector.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
A cast whose target struct type repeats a field name fails the task when Comet runs it natively. Spark allows the cast as long as each pair of fields casts, so CAST(s AS STRUCT<x: INT, x: INT>) over a STRUCT<p: INT, q: INT> column returns {1, 10}. Comet's native cast_struct_to_struct builds the result with the target fields, and the projection itself works: to_json over the cast matches Spark with {"x":1,"x":10}. Importing the result on the JVM then fails, because Java Arrow keys struct children by name and the two x children collapse into one:
java.lang.IllegalStateException: ArrowArray struct has 2 children (expected 1)
at org.apache.arrow.util.Preconditions.checkState(Preconditions.java:562)
at org.apache.arrow.c.ArrayImporter.doImport(ArrayImporter.java:92)
at org.apache.arrow.c.ArrayImporter.importChild(ArrayImporter.java:83)
at org.apache.arrow.c.ArrayImporter.doImport(ArrayImporter.java:101)
at org.apache.arrow.c.ArrayImporter.importArray(ArrayImporter.java:68)
at org.apache.arrow.c.ArrowImporter.importVector(ArrowImporter.java:62)
at org.apache.comet.vector.NativeUtil.importVector(NativeUtil.scala:264)
at org.apache.comet.vector.NativeUtil.getNextBatch(NativeUtil.scala:211)
at org.apache.comet.CometExecIterator.getNextBatch(CometExecIterator.scala:236)
The same happens when the struct is nested in an array or a map value.
Steps to reproduce
Default configs, reproduced on main at fef94f6cd with Spark 4.1.3:
CREATE TABLE ts (
s STRUCT<p: INT, q: INT>,
arr ARRAY<STRUCT<p: INT, q: INT>>,
m MAP<STRING, STRUCT<p: INT, q: INT>>) USING parquet;
INSERT INTO ts VALUES
(named_struct('p', 1, 'q', 10), array(named_struct('p', 1, 'q', 10)),
map('k', named_struct('p', 1, 'q', 10))),
(named_struct('p', 2, 'q', NULL), array(), map()),
(NULL, NULL, NULL);
SELECT CAST(s AS STRUCT<x: INT, x: INT>) FROM ts; -- IllegalStateException
SELECT CAST(arr AS ARRAY<STRUCT<x: INT, x: INT>>) FROM ts; -- IllegalStateException
SELECT CAST(m AS MAP<STRING, STRUCT<x: INT, x: INT>>) FROM ts; -- IllegalStateException
SELECT CAST(s AS STRUCT<x: INT, y: INT>) FROM ts; -- matches Spark
SELECT to_json(CAST(s AS STRUCT<x: INT, x: INT>)) FROM ts; -- matches Spark
The plan is CometProject over CometNativeScan. Spark returns {1, 10}, {2, null} and null for the first query.
Expected behavior
Either match Spark or fall back. The smallest fix is probably for the struct branch of CometCast.isSupported to return Unsupported when the target struct repeats a field name, the same way CometCreateNamedStruct declines repeated names. The array and map branches already recurse into the struct branch, so one check there also covers the nested cases.
Additional context
This is the same Java Arrow limitation as #6251 (arrays_zip, fix in #6324), #5605 and #1015. Main declines structs with repeated field names wherever they would cross into Java Arrow: the shuffle and row conversion checks (#5866), the codegen dispatcher (#5766) and the cache serializer (#6004). Those checks guard the paths that bring a struct into Comet, though, and a native cast creates one. The broadcast exchange admits these types too (CometSink.convert calls supportedDataType with the default allowDuplicateStructFieldNames = true), so declining in the serde that produces the struct is what keeps it out.
Found while checking whether anything in #5603 was worth keeping.
- Ngôn ngữ chính
- Scala
- Star
- 1.3k
- Fork
- 383
- Merge trung bình
- 2 ngày 58 phút
- Pull request đã merge (30 ngày)
- 399
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
-
area:aggregation bug priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/datafusion-comet#6661 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Native from_json with a schema that repeats a field name fails with "ArrowArray struct has 2 children (expected 1)"Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea:expressions area:ffi bug good first issue priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
apache/datafusion-comet#6592 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
arrays_zip with two same-named inputs fails with "ArrowArray struct has 2 children (expected 1)"Có thể đã có người làm @mohitgurav20 đã nhận 7 ngày trước. Đang mởarea:expressions area:ffi bug priority:high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/datafusion-comet#6251 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci: a transient Maven Central failure in lint-java is reported as a scalafix violationCó thể đã có người làm @andygrove đã nhận 16 ngày trước. Đang mởarea:ci bug priority:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
apache/datafusion-comet#6060 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
requires-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/datafusion-comet#5661 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/datafusion-comet
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
com-lihaoyi/mill#7670 ·
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 78/100
snowflakedb/spark-snowflake#673 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Python remote agent example reports tool calls under `tool_trace`, which the decoder ignoresĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
salesforce/evalon#16 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
chipsalliance/chisel#5504 ·
Maintainer thường phản hồi trong vòng 1 ngày