Skip to content

feat: hint at native pyarrow UDF path when the feature is disabled#4892

Open
andygrove wants to merge 1 commit into
apache:mainfrom
andygrove:feature/pyarrow-udf-optin-hint
Open

feat: hint at native pyarrow UDF path when the feature is disabled#4892
andygrove wants to merge 1 commit into
apache:mainfrom
andygrove:feature/pyarrow-udf-optin-hint

Conversation

@andygrove

Copy link
Copy Markdown
Member

Which issue does this PR close?

There is no dedicated tracking issue for this change.

Rationale for this change

spark.comet.exec.pyarrowUdf.enabled is false by default. When it is off, mapInArrow / mapInPandas operators silently fall back to vanilla Spark execution, and nothing in the plan tells the user that a faster native path (CometMapInBatchExec, which passes Arrow columnar data directly to Python UDFs) is available behind a config flag.

Comet already surfaces this kind of guidance for expressions via NativeOptIn + withInfo, which writes a non-fallback [COMET-INFO: ...] message into extended-explain output pointing the user at the config that would opt into a native path. This PR applies the same idiom at the operator level for the PyArrow UDF feature.

What changes are included in this PR?

  • In EliminateRedundantTransitions, the EligibleMapInBatch extractor no longer gates on spark.comet.exec.pyarrowUdf.enabled. It now matches whenever an operator would run natively (version-shimmed mapInArrow / mapInPandas matcher, strippable Comet columnar child, useLargeVarTypes off).
  • The conf check moves into the rewrite arm: when the feature is enabled the operator is rewritten to CometMapInBatchExec as before; when it is disabled the vanilla Spark operator is left in place but annotated with a [COMET-INFO] opt-in hint (reusing NativeOptIn.message so the wording stays consistent with the expression-level hints).

Because the hint reuses the full eligibility check with only the conf inverted, it fires only on operators that would actually go native if the flag were flipped, and stays silent when useLargeVarTypes or a non-Comet child would prevent the rewrite anyway. This is Spark 4.x-only, matching where the feature exists (the 3.x matchers return None).

How are these changes tested?

Added two JVM-only cases to the existing CometMapInBatchSuite (which exercises the rule against a stubbed MapInArrowExec over a Comet leaf without spinning up Python): one asserts the [COMET-INFO] hint and config key appear in extended-explain output when the feature is disabled, and one asserts no hint is emitted when it is enabled. No plan-stability golden files are affected, as no TPCDS query uses these operators.

When spark.comet.exec.pyarrowUdf.enabled is off (the default), mapInArrow
and mapInPandas operators silently fall back to Spark. Annotate the operator
with a non-fallback [COMET-INFO] hint naming the config to opt into the
native CometMapInBatchExec path, reusing the existing NativeOptIn wording.

The hint fires only on operators that would actually run natively if the
flag were flipped: the eligibility check is unchanged, the conf gate simply
moves from the extractor into the rewrite arm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant