## Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the "License"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#importsysfromtypingimportAny,Optional,Unionfrompy4j.java_gatewayimportJavaObjectfrompysparkimportsince,_NoValuefrompyspark._globalsimport_NoValueType
[docs]classRuntimeConfig:"""User-facing configuration API, accessible through `SparkSession.conf`. Options set here are automatically propagated to the Hadoop configuration during I/O. .. versionchanged:: 3.4.0 Supports Spark Connect. """def__init__(self,jconf:JavaObject)->None:"""Create a new RuntimeConfig that wraps the underlying JVM object."""self._jconf=jconf@since(2.0)defset(self,key:str,value:Union[str,int,bool])->None:"""Sets the given Spark runtime configuration property. .. versionchanged:: 3.4.0 Supports Spark Connect. """self._jconf.set(key,value)@since(2.0)defget(self,key:str,default:Union[Optional[str],_NoValueType]=_NoValue)->Optional[str]:"""Returns the value of Spark runtime configuration property for the given key, assuming it is set. .. versionchanged:: 3.4.0 Supports Spark Connect. """self._checkType(key,"key")ifdefaultis_NoValue:returnself._jconf.get(key)else:ifdefaultisnotNone:self._checkType(default,"default")returnself._jconf.get(key,default)@since(2.0)defunset(self,key:str)->None:"""Resets the configuration property for the given key. .. versionchanged:: 3.4.0 Supports Spark Connect. """self._jconf.unset(key)def_checkType(self,obj:Any,identifier:str)->None:"""Assert that an object is of type str."""ifnotisinstance(obj,str):raiseTypeError("expected %s '%s' to be a string (was '%s')"%(identifier,obj,type(obj).__name__))@since(2.4)defisModifiable(self,key:str)->bool:"""Indicates whether the configuration property with the given key is modifiable in the current session. .. versionchanged:: 3.4.0 Supports Spark Connect. """returnself._jconf.isModifiable(key)