Skip to content

feat(jdbc): centralize connection properties from BigQueryConnection and DataSource#4116

Open
keshavdandeva wants to merge 10 commits intomainfrom
jdbc/refactor-connection-properties
Open

feat(jdbc): centralize connection properties from BigQueryConnection and DataSource#4116
keshavdandeva wants to merge 10 commits intomainfrom
jdbc/refactor-connection-properties

Conversation

@keshavdandeva
Copy link
Contributor

b/484306563

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: bigquery Issues related to the googleapis/java-bigquery API. labels Feb 25, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @keshavdandeva, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the way connection properties are handled within the BigQuery JDBC driver. By introducing a dedicated DataSource class, the parsing and management of all connection-related parameters are centralized. This change aims to improve the robustness, consistency, and maintainability of the driver's configuration logic, making it easier to add new properties and ensure their correct interpretation across different components.

Highlights

  • Centralized Connection Property Parsing: Refactored connection property parsing logic from being scattered across BigQueryConnection and BigQueryDriver into a new dedicated DataSource class, promoting a single source of truth for connection configuration.
  • Introduction of DataSource Class: A new DataSource class was introduced to encapsulate all connection properties and provide a standardized way to parse them from a JDBC URL, simplifying property management and access.
  • Streamlined Property Access: Updated BigQueryConnection and BigQueryDriver to retrieve connection properties directly from the DataSource object, eliminating redundant URL parsing logic in multiple places.
  • Removal of Redundant Parsing Utilities: Many property parsing methods in BigQueryJdbcUrlUtility were removed or refactored, as their functionality is now handled by the DataSource class, reducing code duplication and improving maintainability.
Changelog
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java
    • Added connectionPoolSize and listenerPoolSize fields.
    • Refactored numerous connection property parsing calls to use the new DataSource object.
    • Added getter methods for connectionPoolSize and listenerPoolSize.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java
    • Updated connect method to use DataSource.fromUrl(connectionUri) for log level and path parsing.
    • Modified getPropertyInfo to use DataSource.fromUrl(url) for OAuth property parsing.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java
    • Overloaded parseOAuthProperties to accept a DataSource object.
    • Updated existing parseOAuthProperties(String url, ...) to call the new overload.
    • Changed property parsing within parseOAuthProperties to use DataSource getters.
    • Updated logic for EXTERNAL_ACCOUNT_AUTH to use DataSource getters for BYOID properties.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java
    • Removed several parse*Property methods (e.g., parseQueryProperties, parseLabels, parseIntProperty, parseLongProperty, parseBooleanProperty, parseOverrideProperties, parseJobCreationMode, parseBYOIDProperty, getConnectionPropertyDefaultValue, and various parse*InSecs and parse*PoolSize methods).
    • Modified parsePropertiesMap to parsePropertiesMapFromValue with an updated signature.
    • Removed unused imports related to URL decoding.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnection.java
    • Modified constructor to retrieve listenerPoolSize directly from the BigQueryConnection object instead of parsing from the URL.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/DataSource.java
    • Added new fields for various connection properties, including OAuth, BYOID, endpoint overrides, private service connect, and connection/listener pool sizes.
    • Introduced a static PROPERTY_SETTERS map to dynamically set DataSource properties from URL parameters.
    • Added a static fromUrl(String url) factory method to parse a JDBC URL into a DataSource instance.
    • Updated createProperties to include new connection pool properties.
    • Implemented comprehensive getters and setters for all connection properties, often including default value logic.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtilityTest.java
    • Updated OAuth utility tests to reflect the new DataSource-based property parsing and override property handling.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtilityTest.java
    • Removed numerous tests for URL parsing methods that were deprecated or moved to the DataSource class.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnectionTest.java
    • Updated pooled connection tests to mock BigQueryConnection's getListenerPoolSize getter.
  • google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/PooledConnectionDataSourceTest.java
    • Modified pooled connection data source tests to use DataSource properties and mock BigQueryConnection getters.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request centralizes connection property handling by introducing DataSource.fromUrl and refactoring BigQueryConnection to use it, aiming to improve maintainability and reduce code duplication. However, it introduces a critical functional regression in endpoint overrides, which could bypass private endpoints and violate security policies. There is also a potential NullPointerException in BigQueryJdbcOAuthUtility during authentication type retrieval, leading to application crashes. Additionally, consider improving consistency in default value handling and refactoring a large constructor for better readability.

@keshavdandeva
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a significant and valuable refactoring that centralizes connection property handling into the DataSource class. This greatly improves code organization and maintainability. My review focuses on ensuring the new implementation is fully equivalent to the old one and points out a few areas where regressions may have been introduced or where the code can be further simplified. I've identified a couple of high-severity issues related to missing default values for some properties and incorrect parsing logic, which could affect specific authentication configurations and property handling. I've also included some medium-severity suggestions for improving code clarity and robustness.

@keshavdandeva
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a well-executed refactoring that centralizes connection property parsing into the DataSource class. This significantly improves the code's structure and maintainability by creating a single source of truth for connection properties. The new DataSource.fromUrl factory method is a clean and effective implementation. My review includes a couple of suggestions to remove minor code redundancies that arose from this refactoring, further improving code clarity.

@keshavdandeva
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request centralizes connection property handling from BigQueryConnection into the DataSource class, which is a significant improvement for code clarity and maintainability. The changes are well-implemented for the most part. My feedback focuses on a few areas where the centralization could be more complete to further improve the design, and one instance of code duplication that could be addressed.

@keshavdandeva
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively centralizes connection property management by introducing and utilizing a DataSource class. This refactoring significantly cleans up the BigQueryConnection constructor and removes redundant parsing logic from various utility classes. The changes are well-executed and improve the overall design. I have one minor suggestion to further simplify the code.

@keshavdandeva keshavdandeva marked this pull request as ready for review February 27, 2026 16:44
@keshavdandeva keshavdandeva requested review from a team as code owners February 27, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/java-bigquery API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant