You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "lisancao (via GitHub)" <gi...@apache.org> on 2026/05/07 00:18:00 UTC

[PR] Fix SparkPipelinesHook for Spark Connect connections [airflow]

lisancao opened a new pull request, #66498:
URL: https://github.com/apache/airflow/pull/66498

   The Spark 4.x `spark-pipelines` CLI is Connect-native (uses `SparkSession.builder.getOrCreate()` and rejects `--master` / `--deploy-mode` with `SparkException: Remote cannot be specified with master and/or deploy
   mode`), but `SparkPipelinesHook` inherits from `SparkSubmitHook` and unconditionally emits the spark-submit cluster-manager flags. The bash launcher itself also starts a JVM `SparkContext` that binds an in-process Connect server, colliding with a long-running daemon when `SPARK_REMOTE` is set.
   
   This makes `SparkPipelinesOperator` unusable against any `spark_connect`- typed connection even though `SparkConnectHook` ships in the same provider.
   
   The fix overrides `SparkPipelinesHook._resolve_connection()`: when the configured `conn_id` resolves to a `spark_connect` connection, populate `spark_remote` from `SparkConnectHook.get_connection_url()` and zero out the cluster-manager fields. Downstream methods then branch on `self._connection["spark_remote"]`:
   
   * `_get_spark_binary_path()` returns `[sys.executable, "-m", "pyspark.pipelines.cli"]` for Connect connections (bypasses the bash launcher's JVM SparkContext) and `["spark-pipelines"]` for everything else.
   * `_build_spark_pipelines_command()` skips `_build_spark_common_args()`  for Connect (no `--master` / `--deploy-mode` / `--name`).
   * `submit_pipeline()` sets `SPARK_REMOTE` in the subprocess environment, preserving any caller-supplied override via `env_vars` for failover.
   
   Spark-submit-style behaviour (`spark` / `yarn` / `k8s` connection types) is unchanged, connection-lookup failures fall through to the parent's resolver. All existing tests pass without modification.
   
   Adds three tests for the spark_connect path covering (a) command shape without cluster-manager flags, (b) `SPARK_REMOTE` injection from the connection URI, and (c) caller-supplied `SPARK_REMOTE` preservation.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.7, 1M context)
   
   Generated-by: Claude Code (Opus 4.7) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix SparkPipelinesHook for Spark Connect connections [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #66498:
URL: https://github.com/apache/airflow/pull/66498#issuecomment-4393136791

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our [Contributors' Guide](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example Dag that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix SparkPipelinesHook for Spark Connect connections [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #66498:
URL: https://github.com/apache/airflow/pull/66498#issuecomment-4414316547

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix SparkPipelinesHook for Spark Connect connections [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #66498:
URL: https://github.com/apache/airflow/pull/66498


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org