Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions python/pyspark/errors/error_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,99 +39,99 @@
"Function `<func_name>` should return Column, got <return_type>."
]
},
"NOT_AN_INTEGER" : {
"NOT_BOOL" : {
"message" : [
"Argument `<arg_name>` should be a integer, got <arg_type>."
"Argument `<arg_name>` should be a bool, got <arg_type>."
]
},
"NOT_A_BOOLEAN" : {
"NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_LIST_OR_STR_OR_TUPLE" : {
"message" : [
"Argument `<arg_name>` should be a boolean, got <arg_type>."
"Argument `<arg_name>` should be a bool, dict, float, int, str or tuple, got <arg_type>."
]
},
"NOT_A_COLUMN" : {
"NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_STR" : {
"message" : [
"Argument `<arg_name>` should be a Column, got <arg_type>."
"Argument `<arg_name>` should be a bool, dict, float, int or str, got <arg_type>."
]
},
"NOT_A_DATAFRAME" : {
"NOT_BOOL_OR_LIST" : {
"message" : [
"Argument `<arg_name>` must be a DataFrame, got <arg_type>."
"Argument `<arg_name>` should be a bool or list, got <arg_type>."
]
},
"NOT_A_DICT" : {
"NOT_BOOL_OR_STR" : {
"message" : [
"Argument `<arg_name>` should be a dict, got <arg_type>."
"Argument `<arg_name>` should be a bool or str, got <arg_type>."
]
},
"NOT_A_STRING" : {
"NOT_COLUMN" : {
"message" : [
"Argument `<arg_name>` should be a str, got <arg_type>."
"Argument `<arg_name>` should be a Column, got <arg_type>."
]
},
"NOT_BOOL_OR_DICT_OR_FLOAT_OR_INTEGER_OR_LIST_OR_STRING_OR_TUPLE" : {
"NOT_COLUMN_OR_DATATYPE_OR_STR" : {
"message" : [
"Argument `<arg_name>` should be a boolean, dict, float, integer, string or tuple, got <arg_type>."
"Argument `<arg_name>` should be a Column, str or DataType, but got <arg_type>."
]
},
"NOT_BOOL_OR_DICT_OR_FLOAT_OR_INTEGER_OR_STRING" : {
"NOT_COLUMN_OR_FLOAT_OR_INT_OR_LIST_OR_STR" : {
"message" : [
"Argument `<arg_name>` should be a boolean, dict, float, integer or string, got <arg_type>."
"Argument `<arg_name>` should be a column, float, integer, list or string, got <arg_type>."
]
},
"NOT_BOOL_OR_LIST" : {
"NOT_COLUMN_OR_INT" : {
"message" : [
"Argument `<arg_name>` should be a boolean or list, got <arg_type>."
"Argument `<arg_name>` should be a Column or int, got <arg_type>."
]
},
"NOT_BOOL_OR_STRING" : {
"NOT_COLUMN_OR_INT_OR_STR" : {
"message" : [
"Argument `<arg_name>` should be a boolean or string, got <arg_type>."
"Argument `<arg_name>` should be a Column, int or str, got <arg_type>."
]
},
"NOT_COLUMN_OR_DATATYPE_OR_STRING" : {
"NOT_COLUMN_OR_STR" : {
"message" : [
"Argument `<arg_name>` should be a Column or str or DataType, but got <arg_type>."
"Argument `<arg_name>` should be a Column or str, got <arg_type>."
]
},
"NOT_COLUMN_OR_FLOAT_OR_INTEGER_OR_LIST_OR_STRING" : {
"NOT_DATAFRAME" : {
"message" : [
"Argument `<arg_name>` should be a column, float, integer, list or string, got <arg_type>."
"Argument `<arg_name>` must be a DataFrame, got <arg_type>."
]
},
"NOT_COLUMN_OR_INTEGER" : {
"NOT_DICT" : {
"message" : [
"Argument `<arg_name>` should be a Column or int, got <arg_type>."
"Argument `<arg_name>` should be a dict, got <arg_type>."
]
},
"NOT_COLUMN_OR_INTEGER_OR_STRING" : {
"NOT_FLOAT_OR_INT" : {
"message" : [
"Argument `<arg_name>` should be a Column, int or str, got <arg_type>."
"Argument `<arg_name>` should be a float or int, got <arg_type>."
]
},
"NOT_COLUMN_OR_STRING" : {
"NOT_FLOAT_OR_INT_OR_LIST_OR_STR" : {
"message" : [
"Argument `<arg_name>` should be a Column or str, got <arg_type>."
"Argument `<arg_name>` should be a float, int, list or str, got <arg_type>."
]
},
"NOT_FLOAT_OR_INTEGER" : {
"NOT_INT" : {
"message" : [
"Argument `<arg_name>` should be a float or integer, got <arg_type>."
"Argument `<arg_name>` should be an int, got <arg_type>."
]
},
"NOT_FLOAT_OR_INTEGER_OR_LIST_OR_STRING" : {
"NOT_LIST_OR_STR_OR_TUPLE" : {
"message" : [
"Argument `<arg_name>` should be a float, integer, list or string, got <arg_type>."
"Argument `<arg_name>` should be a list, str or tuple, got <arg_type>."
]
},
"NOT_LIST_OR_STRING_OR_TUPLE" : {
"NOT_LIST_OR_TUPLE" : {
"message" : [
"Argument `<arg_name>` should be a list, string or tuple, got <arg_type>."
"Argument `<arg_name>` should be a list or tuple, got <arg_type>."
]
},
"NOT_LIST_OR_TUPLE" : {
"NOT_STR" : {
"message" : [
"Argument `<arg_name>` should be a list or tuple, got <arg_type>."
"Argument `<arg_name>` should be a str, got <arg_type>."
]
},
"UNSUPPORTED_NUMPY_ARRAY_SCALAR" : {
Expand All @@ -141,17 +141,17 @@
},
"UNSUPPORTED_PARAM_TYPE_FOR_HIGHER_ORDER_FUNCTION" : {
"message" : [
"Function `<func_name>` should use only POSITIONAL or POSITIONAL OR KEYWORD arguments"
"Function `<func_name>` should use only POSITIONAL or POSITIONAL OR KEYWORD arguments."
]
},
"WRONG_NUM_ARGS_FOR_HIGHER_ORDER_FUNCTION" : {
"message" : [
"Function `<func_name>` should take between 1 and 3 arguments, but provided function takes <num_args>"
"Function `<func_name>` should take between 1 and 3 arguments, but provided function takes <num_args>."
]
},
"WRONG_NUM_COLUMNS" : {
"message" : [
"Function `<func_name>` should take at least <num_cols> columns"
"Function `<func_name>` should take at least <num_cols> columns."
]
}
}
Expand Down
28 changes: 14 additions & 14 deletions python/pyspark/sql/connect/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def alias(self, alias: str) -> "DataFrame":
def colRegex(self, colName: str) -> Column:
if not isinstance(colName, str):
raise PySparkTypeError(
error_class="NOT_A_STRING",
error_class="NOT_STR",
message_parameters={"arg_name": "colName", "arg_type": type(colName).__name__},
)
return Column(UnresolvedRegex(colName))
Expand Down Expand Up @@ -232,7 +232,7 @@ def repartition( # type: ignore[misc]
)
else:
raise PySparkTypeError(
error_class="NOT_COLUMN_OR_STRING",
error_class="NOT_COLUMN_OR_STR",
message_parameters={
"arg_name": "numPartitions",
"arg_type": type(numPartitions).__name__,
Expand Down Expand Up @@ -574,7 +574,7 @@ def withColumnRenamed(self, existing: str, new: str) -> "DataFrame":
def withColumnsRenamed(self, colsMap: Dict[str, str]) -> "DataFrame":
if not isinstance(colsMap, dict):
raise PySparkTypeError(
error_class="NOT_A_DICT",
error_class="NOT_DICT",
message_parameters={"arg_name": "colsMap", "arg_type": type(colsMap).__name__},
)

Expand All @@ -587,12 +587,12 @@ def _show_string(
) -> str:
if not isinstance(n, int) or isinstance(n, bool):
raise PySparkTypeError(
error_class="NOT_AN_INTEGER",
error_class="NOT_INT",
message_parameters={"arg_name": "n", "arg_type": type(n).__name__},
)
if not isinstance(vertical, bool):
raise PySparkTypeError(
error_class="NOT_A_BOOLEAN",
error_class="NOT_BOOL",
message_parameters={"arg_name": "vertical", "arg_type": type(vertical).__name__},
)

Expand All @@ -604,7 +604,7 @@ def _show_string(
_truncate = int(truncate)
except ValueError:
raise PySparkTypeError(
error_class="NOT_A_BOOLEAN",
error_class="NOT_BOOL",
message_parameters={
"arg_name": "truncate",
"arg_type": type(truncate).__name__,
Expand Down Expand Up @@ -836,7 +836,7 @@ def intersectAll(self, other: "DataFrame") -> "DataFrame":
def where(self, condition: Union[Column, str]) -> "DataFrame":
if not isinstance(condition, (str, Column)):
raise PySparkTypeError(
error_class="NOT_COLUMN_OR_STRING",
error_class="NOT_COLUMN_OR_STR",
message_parameters={"arg_name": "condition", "arg_type": type(condition).__name__},
)
return self.filter(condition)
Expand All @@ -856,7 +856,7 @@ def fillna(
) -> "DataFrame":
if not isinstance(value, (float, int, str, bool, dict)):
raise PySparkTypeError(
error_class="NOT_BOOL_OR_DICT_OR_FLOAT_OR_INTEGER_OR_STRING",
error_class="NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_STR",
message_parameters={"arg_name": "value", "arg_type": type(value).__name__},
)
if isinstance(value, dict):
Expand Down Expand Up @@ -943,7 +943,7 @@ def dropna(
_cols = list(subset)
else:
raise PySparkTypeError(
error_class="NOT_LIST_OR_STRING_OR_TUPLE",
error_class="NOT_LIST_OR_STR_OR_TUPLE",
message_parameters={"arg_name": "subset", "arg_type": type(subset).__name__},
)

Expand Down Expand Up @@ -997,7 +997,7 @@ def all_of_(xs: Iterable) -> bool:
valid_types = (bool, float, int, str, list, tuple)
if not isinstance(to_replace, valid_types + (dict,)):
raise PySparkTypeError(
error_class="NOT_BOOL_OR_DICT_OR_FLOAT_OR_INTEGER_OR_LIST_OR_STRING_OR_TUPLE",
error_class="NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_LIST_OR_STR_OR_TUPLE",
message_parameters={
"arg_name": "to_replace",
"arg_type": type(to_replace).__name__,
Expand Down Expand Up @@ -1097,12 +1097,12 @@ def describe(self, *cols: Union[str, List[str]]) -> "DataFrame":
def cov(self, col1: str, col2: str) -> float:
if not isinstance(col1, str):
raise PySparkTypeError(
error_class="NOT_A_STRING",
error_class="NOT_STR",
message_parameters={"arg_name": "col1", "arg_type": type(col1).__name__},
)
if not isinstance(col2, str):
raise PySparkTypeError(
error_class="NOT_A_STRING",
error_class="NOT_STR",
message_parameters={"arg_name": "col2", "arg_type": type(col2).__name__},
)
pdf = DataFrame.withPlan(
Expand Down Expand Up @@ -1224,12 +1224,12 @@ def sampleBy(
col = Column(ColumnReference(col))
elif not isinstance(col, Column):
raise PySparkTypeError(
error_class="NOT_COLUMN_OR_STRING",
error_class="NOT_COLUMN_OR_STR",
message_parameters={"arg_name": "col", "arg_type": type(col).__name__},
)
if not isinstance(fractions, dict):
raise PySparkTypeError(
error_class="NOT_A_DICT",
error_class="NOT_DICT",
message_parameters={"arg_name": "fractions", "arg_type": type(fractions).__name__},
)
for k, v in fractions.items():
Expand Down
Loading