ueshin commented on code in PR #49297:
URL: https://github.com/apache/spark/pull/49297#discussion_r1898120371
##########
python/pyspark/sql/conf.py:
##########
@@ -151,6 +153,119 @@ def isModifiable(self, key: str) -> bool:
"""
return self._jconf.isModifiable(key)
+ @cached_property
+ def spark(self) -> "RuntimeConfigDictWrapper":
+ from py4j.java_gateway import JVMView
+
+ sc = get_active_spark_context()
+ jvm = cast(JVMView, sc._jvm)
+ d = {}
+ for entry in jvm.PythonSQLUtils.listAllSQLConfigs():
+ k = entry._1()
+ default = entry._2()
+ doc = entry._3()
+ ver = entry._4()
+ entry = SQLConfEntry(k, default, doc, ver)
+ entry.__doc__ = doc # So help function work
+ d[k] = entry
+ return RuntimeConfigDictWrapper(self, d, prefix="spark")
+
+ def __setitem__(self, key: Any, val: Any) -> None:
+ if key.startswith("spark."):
+ self.spark[key[6:]] = val
+ else:
+ super().__setattr__(key, val)
+
+ def __getitem__(self, item: Any) -> Union["RuntimeConfigDictWrapper", str]:
+ if item.startswith("spark."):
+ return self.spark[item[6:]]
+ else:
+ return object.__getattribute__(self, item)
Review Comment:
nit: may want `__del__` to be `unset`?
--
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]