Skip to content

Commit

Permalink
fix(datasets): sql_dataset load_args:params must be a tuple (MSSQL on…
Browse files Browse the repository at this point in the history
…ly) (#556)

* fix(datasets): sql_dataset load_args:params must be a tuple (MSSQL only)

Signed-off-by: Andrew Cao <[email protected]>

* Fix mssql test

Signed-off-by: Merel Theisen <[email protected]>

* Update release notes + lint

Signed-off-by: Merel Theisen <[email protected]>

---------

Signed-off-by: Andrew Cao <[email protected]>
Signed-off-by: Merel Theisen <[email protected]>
Co-authored-by: Merel Theisen <[email protected]>
Co-authored-by: Merel Theisen <[email protected]>
Co-authored-by: Ankita Katiyar <[email protected]>
  • Loading branch information
4 people authored Mar 4, 2024
1 parent a04fb2a commit 7f67afd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions kedro-datasets/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion kedro-datasets/kedro_datasets/pandas/sql_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 10 additions & 8 deletions kedro-datasets/tests/pandas/test_sql_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f67afd

Please sign in to comment.