Dev-iL commented on code in PR #74817:
URL: https://github.com/apache/airflow/pull/74817#discussion_r4307062079


##########
providers/amazon/tests/unit/amazon/aws/transfers/test_sql_to_s3.py:
##########
@@ -199,6 +199,41 @@ def test_fix_dtypes_not_called(self, mock_s3_hook):
 
         mock_fix_dtypes.assert_not_called()
 
+    @pytest.mark.parametrize(
+        ("df_type", "file_format", "read_kwargs", "available_engines", 
"should_raise"),
+        [
+            pytest.param("pandas", "parquet", {}, set(), True, 
id="pandas-parquet-no-engine"),
+            pytest.param("pandas", "parquet", {}, {"fastparquet"}, False, 
id="pandas-parquet-fastparquet"),
+            pytest.param(
+                "pandas", "csv", {"dtype_backend": "pyarrow"}, set(), True, 
id="pandas-pyarrow-backend"
+            ),
+            pytest.param("pandas", "csv", {}, set(), False, 
id="pandas-csv-no-engine"),
+            pytest.param("polars", "parquet", {}, set(), False, 
id="polars-parquet-no-engine"),
+        ],
+    )
+    @mock.patch("importlib.util.find_spec")
+    def test_parquet_engine_required(
+        self, mock_find_spec, df_type, file_format, read_kwargs, 
available_engines, should_raise
+    ):
+        mock_find_spec.side_effect = lambda name: object() if name in 
available_engines else None
+        op = SqlToS3Operator(
+            query="query",
+            s3_bucket="bucket",
+            s3_key="key",
+            sql_conn_id="mysql_conn_id",
+            task_id="task_id",
+            df_type=df_type,
+            file_format=file_format,
+            read_kwargs=read_kwargs,
+            dag=None,
+        )
+
+        if should_raise:
+            with pytest.raises(AirflowOptionalProviderFeatureException, 
match=r"\[parquet\]"):
+                op._ensure_parquet_engine()

Review Comment:
   Agreed. Added `test_execute_checks_parquet_engine_before_querying`, which 
drives the raising path through `op.execute(None)` and asserts the hook's 
`get_df` was never called.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to