You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "trisjain-db (via GitHub)" <gi...@apache.org> on 2026/06/22 16:43:00 UTC
[PR] [SPARK-57594][SS] Add spark_confs support to create_auto_cdc_flow [spark]
trisjain-db opened a new pull request, #56671:
URL: https://github.com/apache/spark/pull/56671
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Wires per-flow Spark configuration through to AutoCDC flows on the OSS Spark Connect pipelines path, matching the behavior already supported by regular (relation) flows.
- `python/pyspark/pipelines/flow.py`: add `spark_conf: Dict[str, str]` field to the `AutoCdcFlow` dataclass.
- `python/pyspark/pipelines/api.py`: add `spark_conf: Optional[Dict[str, str]] = None` kwarg (last param, backwards-compatible) to `create_auto_cdc_flow` and thread it into the `AutoCdcFlow` constructor with `spark_conf or {}`.
- `python/pyspark/pipelines/spark_connect_graph_element_registry.py`: in `register_auto_cdc_flow`, replace the hard-coded `sql_conf={}` on the outgoing `DefineFlow` proto with `sql_conf=flow.spark_conf`.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
`pyspark.pipelines.create_auto_cdc_flow` is the only flow-defining API in the `pyspark.pipelines` surface that does not accept a `spark_conf` keyword. The peer APIs all do:
- `append_flow(spark_conf=...)`
- `@table(spark_conf=...)`
- `@materialized_view(spark_conf=...)`
- `@temporary_view(spark_conf=...)`
The `DefineFlow.sql_conf` proto field already exists and is shared by all flow variants, and the Scala server already reads it into `AutoCdcFlow.sqlConf` for use by `FlowAnalysis`. The Python client simply was not populating the field for AutoCDC flows (the registry hard-coded `sql_conf={}`).
Without this kwarg, users of `create_auto_cdc_flow` have no way to apply per-flow Spark configurations. They are forced to set the conf at the pipeline or cluster scope, which then applies to every flow in the pipeline.
This change closes the gap so AutoCDC flows have the same conf-scoping precedence as the other operators: **flow > destination > pipeline > cluster**.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
AFFECTED VERSIONS: master
`pyspark.pipelines.create_auto_cdc_flow` previously had no way to set per-flow Spark configurations, unlike `append_flow` / `@table` / `@materialized_view`. This adds a `spark_conf` keyword argument so users can override session/cluster confs per AutoCDC flow at execution time.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
- [x] Extended `test_create_auto_cdc_flow_with_all_args` to assert `spark_conf` propagates onto the registered flow.
- [x] Added `test_create_auto_cdc_flow_spark_conf_defaults_to_empty` to verify the default is `{}` when the kwarg is omitted.
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
Generated-by: Claude
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57594][SDP] Add spark_confs support to create_auto_cdc_flow [spark]
Posted by "trisjain-db (via GitHub)" <gi...@apache.org>.
trisjain-db commented on code in PR #56671:
URL: https://github.com/apache/spark/pull/56671#discussion_r3705761648
##########
python/pyspark/pipelines/api.py:
##########
@@ -538,6 +538,7 @@ def create_auto_cdc_flow(
except_column_list: Optional[Union[List[str], List[Column]]] = None,
stored_as_scd_type: Optional[Literal[1, 2, "1", "2"]] = None,
name: Optional[str] = None,
+ spark_conf: Optional[Dict[str, str]] = None,
Review Comment:
Sure, I'll make this change to keep it consistent with the other APIs.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57594][SDP] Add spark_confs support to create_auto_cdc_flow [spark]
Posted by "trisjain-db (via GitHub)" <gi...@apache.org>.
trisjain-db commented on code in PR #56671:
URL: https://github.com/apache/spark/pull/56671#discussion_r3554765929
##########
python/pyspark/pipelines/tests/test_auto_cdc_flow.py:
##########
@@ -72,11 +72,27 @@ def test_create_auto_cdc_flow_with_all_args(self):
column_list=[col("id"), col("val")],
stored_as_scd_type=1,
name="my_flow",
+ spark_conf={"spark.sql.shuffle.partitions": "8"},
)
flow = cast(AutoCdcFlow, registry.auto_cdc_flows[0])
self.assertEqual(flow.name, "my_flow")
self.assertEqual(flow.stored_as_scd_type, 1)
+ self.assertEqual(flow.spark_conf, {"spark.sql.shuffle.partitions": "8"})
+
+ def test_create_auto_cdc_flow_spark_conf_defaults_to_empty(self):
+ registry = LocalGraphElementRegistry()
+ with graph_element_registration_context(registry):
+ dp.create_streaming_table("target")
+ dp.create_auto_cdc_flow(
+ target="target",
+ source="source",
+ keys=[col("key")],
+ sequence_by=expr("seq"),
+ )
+
+ flow = cast(AutoCdcFlow, registry.auto_cdc_flows[0])
+ self.assertEqual(flow.spark_conf, {})
Review Comment:
Sure, I have added a test to PythonPipelineSuite, thanks!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57594][SDP] Add spark_confs support to create_auto_cdc_flow [spark]
Posted by "szehon-ho (via GitHub)" <gi...@apache.org>.
szehon-ho commented on PR #56671:
URL: https://github.com/apache/spark/pull/56671#issuecomment-5170064184
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/3c28a9c093f1026d76e53d3eb2b846ffb28465c8
- merged into branch-4.x https://github.com/apache/spark/commit/6225f7ebd92ddfc323e1603f5eea8c7ada839bf0
*Posted by `merge_spark_pr.py`*
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57594][SS] Add spark_confs support to create_auto_cdc_flow [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #56671:
URL: https://github.com/apache/spark/pull/56671#discussion_r3461526317
##########
python/pyspark/pipelines/tests/test_auto_cdc_flow.py:
##########
@@ -72,11 +72,27 @@ def test_create_auto_cdc_flow_with_all_args(self):
column_list=[col("id"), col("val")],
stored_as_scd_type=1,
name="my_flow",
+ spark_conf={"spark.sql.shuffle.partitions": "8"},
)
flow = cast(AutoCdcFlow, registry.auto_cdc_flows[0])
self.assertEqual(flow.name, "my_flow")
self.assertEqual(flow.stored_as_scd_type, 1)
+ self.assertEqual(flow.spark_conf, {"spark.sql.shuffle.partitions": "8"})
+
+ def test_create_auto_cdc_flow_spark_conf_defaults_to_empty(self):
+ registry = LocalGraphElementRegistry()
+ with graph_element_registration_context(registry):
+ dp.create_streaming_table("target")
+ dp.create_auto_cdc_flow(
+ target="target",
+ source="source",
+ keys=[col("key")],
+ sequence_by=expr("seq"),
+ )
+
+ flow = cast(AutoCdcFlow, registry.auto_cdc_flows[0])
+ self.assertEqual(flow.spark_conf, {})
Review Comment:
A note regarding testing completeness: no server-integration test asserts that spark_conf actually reaches AutoCdcFlow.sqlConf end-to-end via PythonPipelineSuite (the other AutoCDC args are tested there).
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57594][SDP] Add spark_confs support to create_auto_cdc_flow [spark]
Posted by "szehon-ho (via GitHub)" <gi...@apache.org>.
szehon-ho closed pull request #56671: [SPARK-57594][SDP] Add spark_confs support to create_auto_cdc_flow
URL: https://github.com/apache/spark/pull/56671
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57594][SDP] Add spark_confs support to create_auto_cdc_flow [spark]
Posted by "anew (via GitHub)" <gi...@apache.org>.
anew commented on code in PR #56671:
URL: https://github.com/apache/spark/pull/56671#discussion_r3694627368
##########
python/pyspark/pipelines/api.py:
##########
@@ -538,6 +538,7 @@ def create_auto_cdc_flow(
except_column_list: Optional[Union[List[str], List[Column]]] = None,
stored_as_scd_type: Optional[Literal[1, 2, "1", "2"]] = None,
name: Optional[str] = None,
+ spark_conf: Optional[Dict[str, str]] = None,
Review Comment:
`spark_conf` is added before `*`, so it becomes positional-or-keyword. If this intentional?
If the intent is strictly a new kwarg, it should be placed after `*` with the existing keyword-only tracking column arguments. The peer APIs (append_flow, table, etc.) all declare spark_conf after the `*` (keyword-only). Here it's positional-or-keyword (placed before `*`). It's still backwards-compatible, but moving it after the `*` would match the established pattern
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org