Skip to content

feat: support SparkJDBCDataset JDBC URLs in credentials - #1462

Open
Shizoqua wants to merge 6 commits into
kedro-org:mainfrom
Shizoqua:feat/jdbc-url-credentials
Open

feat: support SparkJDBCDataset JDBC URLs in credentials#1462
Shizoqua wants to merge 6 commits into
kedro-org:mainfrom
Shizoqua:feat/jdbc-url-credentials

Conversation

@Shizoqua

@Shizoqua Shizoqua commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #1286.

This PR allows spark.SparkJDBCDataset to use credentials.url as the JDBC URL when the explicit url argument is not provided.

Development notes

  • Added fallback URL resolution from credentials["url"].
  • Preserved explicit url precedence over credentials.
  • Avoided mutating the caller's credentials dictionary.
  • Excluded url from the Spark JDBC properties passed to load/save.
  • Added focused tests for credentials URL usage, explicit URL precedence, and the missing URL error path.
  • Updated the docstring example and kedro-datasets/RELEASE.md.

Checked locally:

  • python -m ruff check kedro_datasets/spark/spark_jdbc_dataset.py tests/spark/test_spark_jdbc_dataset.py
  • git diff --check
  • python -m compileall kedro_datasets/spark/spark_jdbc_dataset.py tests/spark/test_spark_jdbc_dataset.py

Attempted locally:

  • python -m pytest tests/spark/test_spark_jdbc_dataset.py did not run because the local environment is missing aiobotocore, which is imported by tests/conftest.py.

Developer Certificate of Origin

The commit includes a Signed-off-by line.

Checklist

  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Updated jsonschema/kedro-catalog-X.XX.json if necessary (not necessary)
  • Added a description of this change in the relevant RELEASE.md file
  • Added tests to cover my changes
  • Received approvals from at least half of the TSC (required for adding a new, non-experimental dataset)

Signed-off-by: shizoqua <hr.lanreshittu@yahoo.com>

@ravi-kumar-pilla ravi-kumar-pilla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kedro PR Review

Generated with review-kedro-pr skill.

Overview

  • Critical: 1 | Suggestions: 3

Thanks @Shizoqua — this aligns SparkJDBCDataset with how SQLTableDataset handles connection strings via credentials, and the implementation looks solid (explicit url precedence, no credentials mutation, url excluded from JDBC properties).

Critical (must fix before merge)

  • CI — detect-secrets / merge-gatekeeper are failing. The hook reports that .secrets.baseline needs updating after the docstring changes. Please run the repo's detect-secrets hook (or detect-secrets scan --update .secrets.baseline) and commit the baseline update.

Suggestions (consider improving)

  • Add @Shizoqua under Community contributions in RELEASE.md.
  • Add a symmetric load() precedence test to match test_save_explicit_url_takes_precedence_over_credentials_url.
  • Optional: cross-reference the SQLTableDataset credentials.con pattern in the docstring.

Notes

  • General review: Focused PR, good tests, backward compatible for existing catalogs with explicit url.
  • PR checklist: Docs and RELEASE updated; tests added; DCO signed.
  • API usage: Correct AbstractDataset usage; no breaking changes for current callers.

Comment thread kedro-datasets/RELEASE.md
Comment thread kedro-datasets/tests/spark/test_spark_jdbc_dataset.py
Comment thread kedro-datasets/kedro_datasets/spark/spark_jdbc_dataset.py Outdated
@ravi-kumar-pilla

Copy link
Copy Markdown
Contributor

Hi @Shizoqua ,

Thanks for the contribution. The code looks good to me. Left minor comments and a required CI fix to go in before we merge this. Otherwise looks nice !! 💯

…ence test, docstring note

Signed-off-by: shizoqua <hr.lanreshittu@yahoo.com>
@Shizoqua
Shizoqua force-pushed the feat/jdbc-url-credentials branch from e5a7b18 to 7d341e0 Compare July 25, 2026 08:20
Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
@Shizoqua

Copy link
Copy Markdown
Contributor Author

thanks @ravi-kumar-pilla i have addressed Suggestions and fixed CI failure

@ravi-kumar-pilla
ravi-kumar-pilla self-requested a review July 27, 2026 13:25

@ravi-kumar-pilla ravi-kumar-pilla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM...thank you @Shizoqua

Signed-off-by: L. R. Couto <57910428+lrcouto@users.noreply.github.com>
@lrcouto

lrcouto commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR @Shizoqua !

One small thing I'd like to point out is that the database URL passed in the credentials is being exposed by the describe() function. You can see it by running:

    db_credentials = {
        "url": "jdbc:postgresql://prod-db.internal:5432/table_name",
        "user": "johndoe",
        "password": "super-safe-password",
    }

    dataset = SparkJDBCDataset(table="table_name", credentials=db_credentials)

    described = dataset._describe()
    print(described)

If you're using pandas.SQLTableDataset as a reference, I think you could just drop the url key from describe() entirely.

Other than this, I think it looks good!

Signed-off-by: shizoqua <hr.lanreshittu@yahoo.com>
@Shizoqua
Shizoqua force-pushed the feat/jdbc-url-credentials branch from b5d885e to cf5958a Compare August 1, 2026 13:40
@Shizoqua

Shizoqua commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for catching that! I’ve updated _describe() to omit the url from credentials entirely and added a test to cover it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support JDBC URL configuration via credentials

3 participants