[pull] main from apache:main#189
Merged
Merged
Conversation
## Which issue does this PR close? Part of #22091. ## Rationale for this change Current async udfs in lambdas fail with generic errors ## What changes are included in this PR? Report an explicit error when trying to create a lambda with async functions ## Are these changes tested? One sqllogictest added to assert the friendly error ## Are there any user-facing changes? What failed before still fail but with a better error
## Which issue does this PR close? - Closes #22135 ## Rationale for this change `FFI_ExecutionPlan` exposes most of the `ExecutionPlan` trait but does not expose `metrics()`. As a result, `ForeignExecutionPlan::metrics()` falls through to the trait default (`None`), so anything downstream of an FFI boundary loses metrics. The most visible breakage is `EXPLAIN ANALYZE`, which renders empty metric blocks for foreign plans; anything calling `DisplayableExecutionPlan::with_metrics(...)` on a plan tree containing foreign nodes is similarly affected. This PR makes foreign plans behave the same as local plans for metric reporting. Metrics are passed as a snapshot, and all atomic-backed counters/gauges/timers are read into plain integer fields at marshal time. Correct because none of the in-tree consumers (`AnalyzeExec`, `DisplayableExecutionPlan`) poll metrics during streaming. ## What changes are included in this PR? - New module `datafusion/ffi/src/metrics.rs` with FFI-stable mirrors of `MetricsSet`, `Metric`, `MetricValue` (all 16 variants), `Label`, `MetricType`, `MetricCategory`, `PruningMetrics`, `RatioMetrics`, and `RatioMergeStrategy`, plus bidirectional `From` conversions. - `MetricValue::Custom { value: Arc<dyn CustomMetricValue> }` is marshalled as `(name, Display output, as_usize())`. On the consumer side it is reconstructed as a small `FfiCustomMetricValue` shim that preserves `Display` and `as_usize()`. `aggregate` becomes a no-op (snapshots are not mergeable) and `as_any` only downcasts to the shim — this is the documented compromise. - `FFI_ExecutionPlan` gains a new `metrics` function pointer (appended after `repartitioned`). `ForeignExecutionPlan::metrics()` is implemented to call through it. - Two trivial accessors added to `RatioMetrics`: `merge_strategy()` and `display_raw_values()` — needed to marshal these otherwise-private fields. - `chrono` added as a direct dependency of `datafusion-ffi` (used for `Timestamp` ↔ unix-nanos conversion). ## Are these changes tested? Yes. New tests, all passing: - 7 unit tests in `datafusion/ffi/src/metrics.rs` round-trip every `MetricValue` variant individually, plus a full `Metric` (value + labels + partition + type + category) and a `MetricsSet`. - `test_ffi_execution_plan_metrics_round_trip` in `datafusion/ffi/src/execution_plan.rs` exercises the full FFI path: builds an `ExecutionPlan` with a `MetricsSet`, wraps it in `FFI_ExecutionPlan`, retrieves metrics via `ForeignExecutionPlan::metrics()` through `mock_foreign_marker_id`, and asserts the aggregated value matches. - `EmptyExec` test helper extended with `with_metrics(MetricsSet)`. Existing test suites still pass: `cargo test -p datafusion-ffi --all-features` and `cargo test -p datafusion-ffi --features integration-tests`. ## Are there any user-facing changes? Yes — this PR adds public API and makes a binary-incompatible change to `FFI_ExecutionPlan`. Please add the `api change` label. - **New public types** in `datafusion_ffi::metrics`: `FFI_MetricsSet`, `FFI_Metric`, `FFI_MetricValue`, `FFI_Label`, `FFI_MetricType`, `FFI_MetricCategory`, `FFI_PruningMetrics`, `FFI_RatioMetrics`, `FFI_RatioMergeStrategy`, and `FfiCustomMetricValue`. - **ABI break for `FFI_ExecutionPlan`**: a new `metrics` function pointer field is appended. Producers and consumers must be rebuilt together, as is already enforced by the major-version check via `datafusion_ffi::version()`. - **New public accessors** on `RatioMetrics`: `merge_strategy()` and `display_raw_values()`. Non-breaking additions. - **`MetricValue::Custom` across FFI is lossy by design**: the underlying `dyn CustomMetricValue` is not preserved; only its `Display` output and `as_usize()` snapshot survive. Documented on `FfiCustomMetricValue`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )