fix(sqllab_export): manually encode CSV output to support utf-8-sig (#34235)

This commit is contained in:
Ahmed Habeeb
2025-07-24 04:44:56 +03:00
committed by GitHub
parent 9099b0f00d
commit 43775e9373
6 changed files with 42 additions and 12 deletions

View File

@@ -67,7 +67,9 @@ def test_get_data_csv(mock_df_to_escaped_csv, processor, mock_query_context):
mock_df_to_escaped_csv.return_value = "col1,col2\n1,a\n2,b\n3,c\n"
result = processor.get_data(df, coltypes)
assert result == "col1,col2\n1,a\n2,b\n3,c\n"
mock_df_to_escaped_csv.assert_called_once_with(df, index=False, encoding="utf-8")
mock_df_to_escaped_csv.assert_called_once_with(
df, index=False, encoding="utf-8-sig"
)
@patch("superset.common.query_context_processor.excel.df_to_excel")
@@ -141,7 +143,9 @@ def test_get_data_empty_dataframe_csv(
mock_df_to_escaped_csv.return_value = "col1,col2\n"
result = processor.get_data(df, coltypes)
assert result == "col1,col2\n"
mock_df_to_escaped_csv.assert_called_once_with(df, index=False, encoding="utf-8")
mock_df_to_escaped_csv.assert_called_once_with(
df, index=False, encoding="utf-8-sig"
)
@patch("superset.common.query_context_processor.excel.df_to_excel")