[WIP][SPARK-40309][PYTHON][PS] Introduce sql_conf context manager for pyspark.sql#37777
Closed
xinrong-meng wants to merge 5 commits intoapache:masterfrom
Closed
[WIP][SPARK-40309][PYTHON][PS] Introduce sql_conf context manager for pyspark.sql#37777xinrong-meng wants to merge 5 commits intoapache:masterfrom
sql_conf context manager for pyspark.sql#37777xinrong-meng wants to merge 5 commits intoapache:masterfrom
Conversation
xinrong-meng
commented
Sep 2, 2022
| """ | ||
| from pyspark.sql.session import SparkSession | ||
|
|
||
| assert isinstance(pairs, dict), "pairs should be a dictionary." |
Member
Author
There was a problem hiding this comment.
Remain the assertion to be consistent with pyspark.pandas.utils.sql_conf.
6197090 to
cb0ba6c
Compare
sql_conf context manager for pyspark.sqlsql_conf context manager for pyspark.sql
sql_conf context manager for pyspark.sqlsql_conf context manager for pyspark.sql
|
Can one of the admins verify this patch? |
HyukjinKwon
reviewed
Sep 5, 2022
|
|
||
|
|
||
| @contextmanager | ||
| def sql_conf(pairs: Dict[str, Any], *, spark: Optional["SparkSession"] = None) -> Iterator[None]: |
Member
There was a problem hiding this comment.
Should probably name it as sqlConf since we follow camelcase in the API. In addition, I think this should be able to be imported via something like from pyspark.sql import sqlConf. Should also document it in the API reference at python/docs
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
Introduce
sql_confcontext manager forpyspark.sql.Why are the changes needed?
That simplifies the control of Spark SQL configuration as below
from
to
Here is such a context manager is in Pandas API on Spark.
We should introduce one in
pyspark.sql, and deduplicate code if possible.Does this PR introduce any user-facing change?
Yes. Users may use the context manager to manage the Spark SQL configuration for a code block.
For example,
How was this patch tested?
Unit tests.