-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(datasets): Added the Experimental PolarsDatabaseDataset #990
base: main
Are you sure you want to change the base?
feat(datasets): Added the Experimental PolarsDatabaseDataset #990
Conversation
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Hey @noklam, @deepyaman, Should we implement Or do you have different thoughts on how this dataset ought to be implemented? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great if there is at least one example on how to use this, maybe with a sqlite database to avoid the setup.
kedro-datasets/kedro_datasets_experimental/polars/polars_database_dataset.py
Show resolved
Hide resolved
kedro-datasets/kedro_datasets_experimental/polars/polars_database_dataset.py
Outdated
Show resolved
Hide resolved
def load(self) -> pl.DataFrame: | ||
load_args = copy.deepcopy(self._load_args) | ||
|
||
if self._filepath: | ||
load_path = get_filepath_str(PurePosixPath(self._filepath), self._protocol) | ||
with self._fs.open(load_path, mode="r") as fs_file: | ||
query = fs_file.read() | ||
else: | ||
query = load_args.pop("sql") | ||
|
||
return pl.read_database( | ||
query=query, | ||
connection=self._connection_str, | ||
**load_args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some docs or checking to reflect this logic
- If filepath exist use it
- Otherwise use sql
- If both are defined, maybe error out or at least log which one is being used?
Ideally I would re-order the argument as well, since the dataset put sql
as the first argument but actually filepath
have higher priority which feels counter-intuitive.
Sorry for the late response; didn't see this. While there may be opportunities to reduce code copying more broadly, most datasets just inherit from
Probably, because Polars supports it. You can make the table name optional but require it for |
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Signed-off-by: Minura Punchihewa <[email protected]>
Hey @noklam and @deepyaman, |
Description
This PR adds the
PolarsDatabaseDataset
to support interactions with databases using Polars.Fixes #853
Development notes
Quite a bit of code has been copied over from
SQLQueryDataset
in this implementation.These changes have been tested,
2. Via the existing and newly added unit tests.Checklist
RELEASE.md
file