Skip to content

feat(bigquery-jdbc): expose BigQueryResultSetMetadata and getField(int) - #14761

Open
rhgoogle wants to merge 3 commits into
googleapis:mainfrom
rhgoogle:feat/expose-resultset-metadata-get-field
Open

rhgoogle wants to merge 3 commits into
googleapis:mainfrom
rhgoogle:feat/expose-resultset-metadata-get-field

Conversation

@rhgoogle

Copy link
Copy Markdown

Make BigQueryResultSetMetadata and getField(int) public so callers unwrapping ResultSetMetaData via ResultSetMetaData.unwrap(BigQueryResultSetMetadata.class) can inspect the underlying BigQuery Field schema metadata (e.g., Field.getMode() and element StandardSQLTypeName for REPEATED columns) without package-private shims or reflection.

@rhgoogle
rhgoogle requested review from a team as code owners October 24, 2026 00:26

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request changes the visibility of BigQueryResultSetMetadata and its getField(int) method to public, adding Javadoc and corresponding unit tests. A review comment suggests improving the robustness of the newly public getField method by validating the column index and throwing a SQLException instead of allowing an IndexOutOfBoundsException to propagate.

Comment on lines 62 to 64
public Field getField(int sqlColumn) {
return this.schemaFieldList.get(sqlColumn - 1);
}

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.

medium

Since BigQueryResultSetMetadata is now a public class and getField(int) is a public method, it should robustly handle invalid column indices. In JDBC, column indices are 1-based, and passing an invalid index (e.g., 0, negative, or greater than the schema size) should throw a SQLException rather than letting a raw IndexOutOfBoundsException propagate.

  public Field getField(int sqlColumn) throws SQLException {
    if (sqlColumn < 1 || sqlColumn > this.schemaFieldList.size()) {
      throw new SQLException("Column index out of bounds: " + sqlColumn);
    }
    return this.schemaFieldList.get(sqlColumn - 1);
  }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — validated 1-based column bounds in getField(int) and threw BigQueryJdbcException (a SQLException subclass) when out of bounds, with unit test coverage.

@rhgoogle

Copy link
Copy Markdown
Author

@logachev PTAL when you have a chance — this exposes BigQueryResultSetMetadata and getField(int) as public so Looker can unwrap ResultSetMetaData directly without a package-private helper or reflection.

@logachev

Copy link
Copy Markdown
Contributor

/gcbrun

This branch has not been deployed

No deployments
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.

3 participants