apache / apache/datafusion-python

Expose SessionContext.add_optimizer_rule for Python-defined logical optimizer rules

オープン
#1,574 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
604
フォーク
174
平均マージ
1日 7時間
マージ済み PR(30日)
4

説明

## Background

`SessionContext::add_optimizer_rule` registers an `Arc` that runs during logical plan optimization. The Python bindings only expose `remove_optimizer_rule`, never the additive side. PR #1557 ultimately landed `add_physical_optimizer_rule` for the physical pipeline via FFI but did not address the logical pipeline.

## Upstream signature

```rust
pub fn add_optimizer_rule(&self, optimizer_rule: Arc)
```

## User value

Lets users add domain-specific logical rewrites (predicate normalization, redundant join elimination, scan pruning informed by external metadata) without forking DataFusion. Complements the existing `remove_optimizer_rule` to round out the surface.

## Why deferred

Blocked upstream. As documented in PR #1557, DataFusion does not currently expose an FFI bridge for the logical `OptimizerRule` / `AnalyzerRule` traits, and there are no Python constructors for `LogicalPlan` node variants -- a pure-Python rule could observe plans but not transform them. The PR #1557 commit history shows an initial attempt at a Python-defined logical rule that was abandoned for this reason. This is filed for tracking; it should be revisited once upstream lands an `FFI_OptimizerRule` (mirroring `FFI_PhysicalOptimizerRule`).

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず、SessionContext.remove_optimizer_rule の既存の Python binding と、PR #1557 の add_physical_optimizer_rule の作業を確認してください。upstream で FFI_OptimizerRule と Python LogicalPlan コンストラクターが提供されたら、この issue を再度確認してください。Python で定義した論理ルールを add_optimizer_rule を通じて登録し、binding を通じて実行できれば完了です。

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

評価

技術スタック
python, rust
領域
data-engineering
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

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

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