-
Couldn't load subscription status.
- Fork 107
feat(datasets): support TableDataset credentials
#1218
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
base: main
Are you sure you want to change the base?
Changes from all commits
f79f46d
1e65087
74cbed1
90db8d2
13e8b3b
bac6695
ce728b9
a7a3159
6bc347c
9f68826
59d72c5
2f8d692
d1747ef
cdf8381
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,7 +33,7 @@ class SaveMode(StrEnum): | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| class TableDataset(ConnectionMixin, AbstractDataset[ir.Table, ir.Table]): | ||||||||||||||||||||||||||||
| """`TableDataset` loads/saves data from/to Ibis table expressions. | ||||||||||||||||||||||||||||
| """``TableDataset`` loads/saves data from/to Ibis table expressions. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Examples: | ||||||||||||||||||||||||||||
| Using the [YAML API](https://docs.kedro.org/en/stable/catalog-data/data_catalog_yaml_examples/): | ||||||||||||||||||||||||||||
|
|
@@ -58,7 +58,7 @@ class TableDataset(ConnectionMixin, AbstractDataset[ir.Table, ir.Table]): | |||||||||||||||||||||||||||
| save_args: | ||||||||||||||||||||||||||||
| materialized: view | ||||||||||||||||||||||||||||
| mode: overwrite | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
gitgud5000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Using the [Python API](https://docs.kedro.org/en/stable/catalog-data/advanced_data_catalog_usage/): | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -96,6 +96,7 @@ def __init__( # noqa: PLR0913 | |||||||||||||||||||||||||||
| table_name: str, | ||||||||||||||||||||||||||||
| database: str | None = None, | ||||||||||||||||||||||||||||
| connection: dict[str, Any] | None = None, | ||||||||||||||||||||||||||||
| credentials: dict[str, Any] | str | None = None, | ||||||||||||||||||||||||||||
| load_args: dict[str, Any] | None = None, | ||||||||||||||||||||||||||||
| save_args: dict[str, Any] | None = None, | ||||||||||||||||||||||||||||
| metadata: dict[str, Any] | None = None, | ||||||||||||||||||||||||||||
|
|
@@ -126,6 +127,9 @@ def __init__( # noqa: PLR0913 | |||||||||||||||||||||||||||
| in a multi-level table hierarchy. | ||||||||||||||||||||||||||||
| connection: Configuration for connecting to an Ibis backend. | ||||||||||||||||||||||||||||
| If not provided, connect to DuckDB in in-memory mode. | ||||||||||||||||||||||||||||
| credentials: Connection information (e.g. | ||||||||||||||||||||||||||||
| user, password, token, account). If provided, these values | ||||||||||||||||||||||||||||
| overlay the base `connection` configuration. | ||||||||||||||||||||||||||||
gitgud5000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
| load_args: Additional arguments passed to the Ibis backend's | ||||||||||||||||||||||||||||
| `read_{file_format}` method. | ||||||||||||||||||||||||||||
| save_args: Additional arguments passed to the Ibis backend's | ||||||||||||||||||||||||||||
|
|
@@ -145,6 +149,16 @@ def __init__( # noqa: PLR0913 | |||||||||||||||||||||||||||
| self._table_name = table_name | ||||||||||||||||||||||||||||
| self._database = database | ||||||||||||||||||||||||||||
| self._connection_config = connection or self.DEFAULT_CONNECTION_CONFIG | ||||||||||||||||||||||||||||
| # Credentials overlay connection config | ||||||||||||||||||||||||||||
| if credentials: | ||||||||||||||||||||||||||||
| if isinstance(credentials, dict): | ||||||||||||||||||||||||||||
| self._connection_config.update(credentials) | ||||||||||||||||||||||||||||
| elif isinstance(credentials, str): | ||||||||||||||||||||||||||||
| raise ValueError( | ||||||||||||||||||||||||||||
| "Connection string credentials are not supported for Ibis TableDataset." | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||
| raise TypeError("Credentials must be a dict or None.") | ||||||||||||||||||||||||||||
|
Comment on lines
+152
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If looking at other datasets, I feel like this may be excessive; most datasets (e.g.
Suggested change
I think what you have with: if credentials:
self._connection_config.update(credentials)should also work (just need to make sure about |
||||||||||||||||||||||||||||
| self.metadata = metadata | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Set load and save arguments, overwriting defaults if provided. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.