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

オープン
#27,155 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Rust
スター
9.6k
フォーク
2.6k
平均マージ
3日 4時間
マージ済み PR(30日)
345

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/datafusion のほかの issue

apache/datafusion の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。