From 7f67afddd5f5dd0b884a8677c26503395aa9b1dc Mon Sep 17 00:00:00 2001 From: andrewcao1 <111729944+andrewcao1@users.noreply.github.com> Date: Mon, 4 Mar 2024 23:25:34 +1100 Subject: [PATCH] fix(datasets): sql_dataset load_args:params must be a tuple (MSSQL only) (#556) * fix(datasets): sql_dataset load_args:params must be a tuple (MSSQL only) Signed-off-by: Andrew Cao * Fix mssql test Signed-off-by: Merel Theisen * Update release notes + lint Signed-off-by: Merel Theisen --------- Signed-off-by: Andrew Cao Signed-off-by: Merel Theisen Co-authored-by: Merel Theisen <49397448+merelcht@users.noreply.github.com> Co-authored-by: Merel Theisen Co-authored-by: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> --- kedro-datasets/RELEASE.md | 3 +++ .../kedro_datasets/pandas/sql_dataset.py | 2 +- .../tests/pandas/test_sql_dataset.py | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/kedro-datasets/RELEASE.md b/kedro-datasets/RELEASE.md index 2ffca13eb..f5569c8ae 100755 --- a/kedro-datasets/RELEASE.md +++ b/kedro-datasets/RELEASE.md @@ -8,9 +8,12 @@ pip install kedro-datasets[pandas-parquetdataset] * Added `NetCDFDataset` for loading and saving `*.nc` files. ## Bug fixes and other changes +* If using MSSQL, `load_args:params` will be typecasted as tuple. + ## Community contributions Many thanks to the following Kedroids for contributing PRs to this release: * [Riley Brady](https://github.com/riley-brady) +* [Andrew Cao](https://github.com/andrewcao1) # Release 2.1.0 diff --git a/kedro-datasets/kedro_datasets/pandas/sql_dataset.py b/kedro-datasets/kedro_datasets/pandas/sql_dataset.py index 24a835f5d..13baf20c3 100644 --- a/kedro-datasets/kedro_datasets/pandas/sql_dataset.py +++ b/kedro-datasets/kedro_datasets/pandas/sql_dataset.py @@ -566,4 +566,4 @@ def adapt_mssql_date_params(self) -> None: except (TypeError, ValueError): new_load_args.append(value) if new_load_args: - self._load_args["params"] = new_load_args + self._load_args["params"] = tuple(new_load_args) diff --git a/kedro-datasets/tests/pandas/test_sql_dataset.py b/kedro-datasets/tests/pandas/test_sql_dataset.py index 669d445e4..08f7ecdda 100644 --- a/kedro-datasets/tests/pandas/test_sql_dataset.py +++ b/kedro-datasets/tests/pandas/test_sql_dataset.py @@ -487,14 +487,16 @@ def test_adapt_mssql_date_params(self, mocker): ds = SQLQueryDataset( sql=SQL_QUERY, credentials={"con": MSSQL_CONNECTION}, load_args=load_args ) - assert ds._load_args["params"] == [ - "2023-01-01T00:00:00", - "2023-01-01T20:26", - "2023", - "test", - 1.0, - 100, - ] + assert ds._load_args["params"] == tuple( + [ + "2023-01-01T00:00:00", + "2023-01-01T20:26", + "2023", + "test", + 1.0, + 100, + ] + ) def test_adapt_mssql_date_params_wrong_input(self, mocker): """Test that the adapt_mssql_date_params