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
5 changes: 0 additions & 5 deletions python/pyspark/errors/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1208,11 +1208,6 @@
"Value for `<arg_name>` must be a non-empty string, got '<arg_value>'."
]
},
"VALUE_NOT_PEARSON": {
"message": [
"Value for `<arg_name>` only supports 'pearson', got '<arg_value>'."
]
},
"VALUE_NOT_PLAIN_COLUMN_REFERENCE": {
"message": [
"Value `<val>` in `<field_name>` should be a plain column reference such as `df.col` or `col('column')`."
Expand Down
4 changes: 2 additions & 2 deletions python/pyspark/sql/classic/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1693,8 +1693,8 @@ def corr(self, col1: str, col2: str, method: Optional[str] = None) -> float:
method = "pearson"
if not method == "pearson":
raise PySparkValueError(
errorClass="VALUE_NOT_PEARSON",
messageParameters={"arg_name": "method", "arg_value": method},
errorClass="VALUE_NOT_ALLOWED",
messageParameters={"arg_name": "method", "allowed_values": "['pearson']"},
)
return self._jdf.stat().corr(col1, col2, method)

Expand Down
4 changes: 2 additions & 2 deletions python/pyspark/sql/connect/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,8 +1663,8 @@ def corr(self, col1: str, col2: str, method: Optional[str] = None) -> float:
method = "pearson"
if not method == "pearson":
raise PySparkValueError(
errorClass="VALUE_NOT_PEARSON",
messageParameters={"arg_name": "method", "arg_value": method},
errorClass="VALUE_NOT_ALLOWED",
messageParameters={"arg_name": "method", "allowed_values": "['pearson']"},
)
table, _ = DataFrame(
plan.StatCorr(child=self._plan, col1=col1, col2=col2, method=method),
Expand Down
15 changes: 8 additions & 7 deletions python/pyspark/sql/tests/connect/test_connect_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,14 @@ def test_stat_corr(self):
"arg_type": "int",
},
)
with self.assertRaises(ValueError) as context:
(self.connect.read.table(self.tbl_name2).stat.corr("col1", "col3", "spearman"),)
self.assertTrue(
"Currently only the calculation of the Pearson Correlation "
+ "coefficient is supported."
in str(context.exception)
)
with self.assertRaises(PySparkValueError) as pe:
self.connect.read.table(self.tbl_name2).stat.corr("col1", "col3", "spearman")

self.check_error(
exception=pe.exception,
errorClass="VALUE_NOT_ALLOWED",
messageParameters={"arg_name": "method", "allowed_values": "['pearson']"},
)

def test_stat_approx_quantile(self):
# SPARK-41069: Test the stat.approxQuantile method
Expand Down