diff --git a/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py b/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py index d7c411b172b41..eba5292dd2d75 100644 --- a/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py +++ b/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py @@ -279,14 +279,14 @@ def _resolve_connection(self) -> dict[str, Any]: if not self.spark_binary: self.spark_binary = extra.get("spark-binary", DEFAULT_SPARK_BINARY) if self.spark_binary is not None and self.spark_binary not in ALLOWED_SPARK_BINARIES: - raise RuntimeError( - f"The spark-binary extra can be on of {ALLOWED_SPARK_BINARIES} and it" + raise ValueError( + f"The spark-binary extra can be one of {ALLOWED_SPARK_BINARIES} and it" f" was `{self.spark_binary}`. Please make sure your spark binary is one of the" f" allowed ones and that it is available on the PATH" ) conn_spark_home = extra.get("spark-home") if conn_spark_home: - raise RuntimeError( + raise ValueError( "The `spark-home` extra is not allowed any more. Please make sure one of" f" {ALLOWED_SPARK_BINARIES} is available on the PATH, and set `spark-binary`" " if needed." diff --git a/providers/apache/spark/tests/unit/apache/spark/hooks/test_spark_submit.py b/providers/apache/spark/tests/unit/apache/spark/hooks/test_spark_submit.py index 2f6c6d2109040..e19a7f736118e 100644 --- a/providers/apache/spark/tests/unit/apache/spark/hooks/test_spark_submit.py +++ b/providers/apache/spark/tests/unit/apache/spark/hooks/test_spark_submit.py @@ -536,11 +536,11 @@ def test_resolve_connection_custom_spark_binary_allowed_in_hook(self): SparkSubmitHook(conn_id="spark_binary_set", spark_binary="another-custom-spark-submit") def test_resolve_connection_spark_binary_extra_not_allowed_runtime_error(self): - with pytest.raises(RuntimeError): + with pytest.raises(ValueError): SparkSubmitHook(conn_id="spark_custom_binary_set") def test_resolve_connection_spark_home_not_allowed_runtime_error(self): - with pytest.raises(RuntimeError): + with pytest.raises(ValueError): SparkSubmitHook(conn_id="spark_home_set") def test_resolve_connection_spark_binary_default_value_override(self):