Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yaml
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
- 76/100
Hướng nghiên cứu
Bắt đầu với datafusion/substrait/src/logical_plan/consumer/expr/scalar_function.rs, nơi issue cho biết consumer hiện chỉ ánh xạ các tên bitwise_; hãy kiểm tra các ánh xạ và bài kiểm tra ở gần đó. Xác minh rằng các lệnh gọi tiêu chuẩn shift_left và shift_right được ánh xạ sang các toán tử dịch bit của DataFusion, đồng thời kiểm tra cả cách đặt tên của producer. Hoàn thành khi các tên tiêu chuẩn hoạt động trong plan được tái hiện và shift_right_unsigned báo lỗi rõ ràng rằng tính năng này không được hỗ trợ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
I found this inconsistency while checking DataFusion against a formalization of Substrait plan semantics, when plans that call Substrait's standard shift functions were rejected by from_substrait_plan.
Substrait's functions_arithmetic.yaml defines shift_left, shift_right and shift_right_unsigned (added in Substrait v0.74.0, substrait-io/substrait#799). DataFusion's consumer maps the names bitwise_shift_left and bitwise_shift_right to its shift operators, and rejects a plan that calls the standard names with Unsupported function name: "shift_left". The producer writes the same non-standard names, so a DataFusion plan with a << 1 calls bitwise_shift_left, which other consumers won't find in the extension. The current names may simply predate the standard functions.
To Reproduce
DataFusion 55.0.0 (Python bindings, datafusion==55.0.0, built on DataFusion 55.1.0); the same on 51.0.0. The consumer's mapping on main still lists only the bitwise_ names (datafusion/substrait/src/logical_plan/consumer/expr/scalar_function.rs).
# uv run --no-project --with datafusion==55.0.0 --with "substrait>=0.37" python DF-10.py
import json
import datafusion
from datafusion import SessionContext
from datafusion.substrait import Consumer, Producer, Serde
from google.protobuf import json_format
from substrait.plan_pb2 import Plan
print("datafusion", datafusion.__version__)
ctx = SessionContext()
# SELECT shift_left(a, 1), shift_right(a, 1) FROM (VALUES (CAST(5 AS INT))) t(a),
# written with the functions of Substrait's functions_arithmetic.yaml.
urn = "extension:io.substrait:functions_arithmetic"
def call(anchor):
return {"scalarFunction": {"functionReference": anchor,
"outputType": {"i32": {"nullability": "NULLABILITY_REQUIRED"}},
"arguments": [
{"value": {"selection": {"directReference": {"structField": {"field": 0}}, "rootReference": {}}}},
{"value": {"literal": {"i32": 1}}}]}}
plan = {
"extensionUrns": [{"extensionUrnAnchor": 1, "urn": urn}],
"extensions": [
{"extensionFunction": {"extensionUrnReference": 1, "functionAnchor": 1, "name": "shift_left:i32_i32"}},
{"extensionFunction": {"extensionUrnReference": 1, "functionAnchor": 2, "name": "shift_right:i32_i32"}}],
"relations": [{"root": {"names": ["l", "r"], "input": {"project": {
"common": {"emit": {"outputMapping": [1, 2]}},
"input": {"read": {
"baseSchema": {"names": ["a"], "struct": {"types": [{"i32": {"nullability": "NULLABILITY_REQUIRED"}}], "nullability": "NULLABILITY_REQUIRED"}},
"virtualTable": {"expressions": [{"fields": [{"literal": {"i32": 5}}]}]}}},
"expressions": [call(1), call(2)]}}}}]}
msg = json_format.ParseDict(plan, Plan())
try:
lp = Consumer.from_substrait_plan(ctx, Serde.deserialize_bytes(msg.SerializeToString()))
print(ctx.create_dataframe_from_logical_plan(lp).to_pydict())
except Exception as e:
print("consumer error:", e)
# The producer, for its part, names these functions bitwise_shift_left / bitwise_shift_right.
ctx.sql("CREATE TABLE t (a INT) AS VALUES (5)").collect()
p = Producer.to_substrait_plan(ctx.sql("SELECT a << 1 AS l, a >> 1 AS r FROM t").logical_plan(), ctx)
out = Plan(); out.ParseFromString(p.encode())
print("producer extensions:", [e.extension_function.name for e in out.extensions])
Output:
datafusion 55.0.0
consumer error: DataFusion error: This feature is not implemented: Unsupported function name: "shift_left"
producer extensions: ['bitwise_shift_left', 'bitwise_shift_right']
With the two names changed to bitwise_shift_left and bitwise_shift_right, the same plan runs and returns {'l': [10], 'r': [2]}, so only the name is in the way.
Expected behavior
The consumer accepts shift_left and shift_right and maps them to Operator::BitwiseShiftLeft and Operator::BitwiseShiftRight, so the plan above returns {'l': [10], 'r': [2]}. The producer could write the standard names too, as was done for is_nan, sign and others in #16949. shift_right_unsigned has no DataFusion operator, so an explicit "not supported" error would fit it.
Additional context
- The definitions: https://github.com/substrait-io/substrait/blob/main/extensions/functions_arithmetic.yaml (
shift_left,shift_right,shift_right_unsigned). - #16949 / #16950 added other missing Substrait-to-DataFusion name mappings in the same table.
Willingness to contribute
I would like to contribute a fix for this bug, but request guidance from the DataFusion community
- Ngôn ngữ chính
- Rust
- Star
- 9.6k
- Fork
- 2.6k
- Merge trung bình
- 3 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 331
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- 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
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsCó thể đã có người làm @joseph-isaacs đã 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 72/100
apache/datafusion#27050 ·
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 75/100
apache/datafusion#26999 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
apache/datafusion#26998 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`repeat` on `LargeUtf8` aborts the process on a result size no allocation can satisfyCó thể đã có người làm @huong8373tt-beep đã nhận 1 ngày trước. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/datafusion#26948 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] atan2 does not normalize -0.0 the way Spark doesCó thể đã có người làm @galaxytemple đã nhận 4 ngày trước. Đang mởbug spark
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/datafusion#26333 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/datafusion
Issue tương tự
-
Perl - Readme DriftCó thể đã có người làm @Omnideth đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
CommunityToolkit/Aspire#2375 ·
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 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ 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 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày