@@ -252,8 +252,9 @@ def explain(
252252 if not (is_no_argument or is_extended_case or is_extended_as_mode or is_mode_case ):
253253 if (extended is not None ) and (not isinstance (extended , (bool , str ))):
254254 raise PySparkTypeError (
255- errorClass = "NOT_BOOL_OR_STR " ,
255+ errorClass = "NOT_EXPECTED_TYPE " ,
256256 messageParameters = {
257+ "expected_type" : "bool or str" ,
257258 "arg_name" : "extended" ,
258259 "arg_type" : type (extended ).__name__ ,
259260 },
@@ -306,8 +307,12 @@ def _show_string(
306307
307308 if not isinstance (vertical , bool ):
308309 raise PySparkTypeError (
309- errorClass = "NOT_BOOL" ,
310- messageParameters = {"arg_name" : "vertical" , "arg_type" : type (vertical ).__name__ },
310+ errorClass = "NOT_EXPECTED_TYPE" ,
311+ messageParameters = {
312+ "expected_type" : "bool" ,
313+ "arg_name" : "vertical" ,
314+ "arg_type" : type (vertical ).__name__ ,
315+ },
311316 )
312317
313318 if isinstance (truncate , bool ) and truncate :
@@ -317,8 +322,9 @@ def _show_string(
317322 int_truncate = int (truncate )
318323 except ValueError :
319324 raise PySparkTypeError (
320- errorClass = "NOT_BOOL " ,
325+ errorClass = "NOT_EXPECTED_TYPE " ,
321326 messageParameters = {
327+ "expected_type" : "bool" ,
322328 "arg_name" : "truncate" ,
323329 "arg_type" : type (truncate ).__name__ ,
324330 },
@@ -1013,8 +1019,12 @@ def __getitem__(
10131019 return Column (jc )
10141020 else :
10151021 raise PySparkTypeError (
1016- errorClass = "NOT_COLUMN_OR_FLOAT_OR_INT_OR_LIST_OR_STR" ,
1017- messageParameters = {"arg_name" : "item" , "arg_type" : type (item ).__name__ },
1022+ errorClass = "NOT_EXPECTED_TYPE" ,
1023+ messageParameters = {
1024+ "expected_type" : "Column, float, integer, list or string" ,
1025+ "arg_name" : "item" ,
1026+ "arg_type" : type (item ).__name__ ,
1027+ },
10181028 )
10191029
10201030 def __getattr__ (self , name : str ) -> Column :
@@ -1285,8 +1295,12 @@ def fillna(
12851295 ) -> ParentDataFrame :
12861296 if not isinstance (value , (float , int , str , bool , dict )):
12871297 raise PySparkTypeError (
1288- errorClass = "NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_STR" ,
1289- messageParameters = {"arg_name" : "value" , "arg_type" : type (value ).__name__ },
1298+ errorClass = "NOT_EXPECTED_TYPE" ,
1299+ messageParameters = {
1300+ "expected_type" : "bool, dict, float, int or str" ,
1301+ "arg_name" : "value" ,
1302+ "arg_type" : type (value ).__name__ ,
1303+ },
12901304 )
12911305
12921306 # Note that bool validates isinstance(int), but we don't want to
@@ -1384,8 +1398,9 @@ def all_of_(xs: Iterable) -> bool:
13841398 valid_types = (bool , float , int , str , list , tuple )
13851399 if not isinstance (to_replace , valid_types + (dict ,)):
13861400 raise PySparkTypeError (
1387- errorClass = "NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_LIST_OR_STR_OR_TUPLE " ,
1401+ errorClass = "NOT_EXPECTED_TYPE " ,
13881402 messageParameters = {
1403+ "expected_type" : "bool, dict, float, int, str or tuple" ,
13891404 "arg_name" : "to_replace" ,
13901405 "arg_type" : type (to_replace ).__name__ ,
13911406 },
@@ -1397,8 +1412,9 @@ def all_of_(xs: Iterable) -> bool:
13971412 and not isinstance (to_replace , dict )
13981413 ):
13991414 raise PySparkTypeError (
1400- errorClass = "NOT_BOOL_OR_FLOAT_OR_INT_OR_LIST_OR_NONE_OR_STR_OR_TUPLE " ,
1415+ errorClass = "NOT_EXPECTED_TYPE " ,
14011416 messageParameters = {
1417+ "expected_type" : "bool, float, int, list, None, str or tuple" ,
14021418 "arg_name" : "value" ,
14031419 "arg_type" : type (value ).__name__ ,
14041420 },
@@ -1648,8 +1664,12 @@ def withColumns(self, *colsMap: Dict[str, Column]) -> ParentDataFrame:
16481664 def withColumn (self , colName : str , col : Column ) -> ParentDataFrame :
16491665 if not isinstance (col , Column ):
16501666 raise PySparkTypeError (
1651- errorClass = "NOT_COLUMN" ,
1652- messageParameters = {"arg_name" : "col" , "arg_type" : type (col ).__name__ },
1667+ errorClass = "NOT_EXPECTED_TYPE" ,
1668+ messageParameters = {
1669+ "expected_type" : "Column" ,
1670+ "arg_name" : "col" ,
1671+ "arg_type" : type (col ).__name__ ,
1672+ },
16531673 )
16541674 return DataFrame (self ._jdf .withColumn (colName , col ._jc ), self .sparkSession )
16551675
0 commit comments