`Expr::Not` and `PhysicalExpr::NotExpr` have different metadata propagation rules

Đang mở
#27,155 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 1 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
57/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend, databases

Hướng nghiên cứu

The reproduction identifies Expr::Not::to_field and physical NotExpr::return_field as the paths with different metadata results. Read those implementations and nearby expression metadata tests first; the issue leaves open which behavior is correct. Decide on consistent propagation rules, add a regression test for the chosen behavior, and verify logical and physical fields agree.

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

Mô tả

bug
Describe the bug

The logical an physical representations of NOT propagate metadata differently.

I'm actually not sure which one is more correct...some metadata uses like "sensor" or "where this value came from" probably are not lying after a NOT operation; however, it's also a little like a function call which would discard its output metadata.

To Reproduce
#[test]
fn not_metadata_differs_between_logical_and_physical() -> Result<()> {
    let schema = Schema::new(vec![Field::new("flag", DataType::Boolean, false)]);
    let df_schema = DFSchema::try_from(schema.clone())?;

    let metadata = FieldMetadata::from(HashMap::from([(
        "source".to_string(),
        "input".to_string(),
    )]));

    let expr = Expr::Not(Box::new(
        col("flag").alias_with_metadata("flag", Some(metadata)),
    ));

    let logical_field = expr.to_field(&df_schema)?.1;
    let physical_expr = create_physical_expr(
        &expr,
        &df_schema,
        &ExecutionProps::new(),
        &PhysicalPlanningContext::default(),
    )?;
    let physical_field = physical_expr.return_field(&schema)?;

    // Logical NOT creates a metadata-free Boolean field.
    assert_eq!(logical_field.metadata().get("source"), None);

    // Physical NotExpr forwards its child's field metadata.
    assert_eq!(
        physical_field.metadata().get("source").map(String::as_str),
        Some("input")
    );

    Ok(())
}
Expected behavior

I'd expect the result to match

Additional context

No response

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 4 giờ
Pull request đã merge (30 ngày)
345

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

Mở trong Codespaces

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.

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

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

Issue tương tự

Thêm issue về Rust

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.