xinrong-meng commented on code in PR #37777:
URL: https://github.com/apache/spark/pull/37777#discussion_r962025957


##########
python/pyspark/sql/utils.py:
##########
@@ -303,3 +304,31 @@ def is_timestamp_ntz_preferred() -> bool:
     """
     jvm = SparkContext._jvm
     return jvm is not None and jvm.PythonSQLUtils.isTimestampNTZPreferred()
+
+
+@contextmanager
+def sql_conf(pairs: Dict[str, Any], *, spark: Optional["SparkSession"] = None) 
-> Iterator[None]:
+    """
+    A convenient context manager to set `value` to the Spark SQL configuration 
`key` and
+    then restores it back when it exits.
+    """
+    from pyspark.sql.session import SparkSession
+
+    assert isinstance(pairs, dict), "pairs should be a dictionary."

Review Comment:
   I was thinking changing the AssertionError to ValueError. However, I decide 
to remain the AssertionError to avoid user-facing change for 
`pyspark.pandas.utils.sql_conf`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to