Skip to content

Conversation

@lperson
Copy link

@lperson lperson commented Nov 30, 2025

closes #13413

@lperson lperson requested review from a team as code owners November 30, 2025 22:23
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lperson, 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 enhances the BigQuery schema inference capabilities by integrating support for default values. Users can now define default expressions for their BigQuery table fields directly within their Go struct definitions, leveraging a new default tag option. This change streamlines schema generation, making it more flexible and reducing the need for manual adjustments when working with BigQuery tables that utilize default column values.

Highlights

  • Default Value Support: Introduced the ability to specify default values for BigQuery fields directly within Go struct tags using a new default tag option.
  • Schema Inference Enhancement: The inferFieldSchema function now accepts and processes a defaultValueExpression, applying it to the generated FieldSchema for supported types like BYTES, NUMERIC, STRING, and various nullable types.
  • Validation and Error Handling: Added new error types (unsupportedDefaultError, unsupportedDefaultUnlessNullableError) to provide clear feedback when default values are used with unsupported field types (e.g., GeographyFieldType) or when a default is provided for a required field that doesn't explicitly support it (e.g., []byte, *big.Rat).
  • Test Coverage: New test cases have been added to schema_test.go to validate the correct inference of default values for various data types and to ensure proper error handling for unsupported default value configurations.
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 introduces support for default values in BigQuery schema inference via struct tags. The implementation is largely sound, adding a default tag option, updating the schema inference logic to handle it, and including new tests. However, there are a few areas for improvement. A key test for tag validation has been removed, which reduces test coverage. Additionally, there's a misleading error message for invalid tags, some inconsistency in the implementation for primitive types, and minor redundancy in new error messages. My review provides specific suggestions to address these points and improve the overall quality of the change.

@lperson
Copy link
Author

lperson commented Nov 30, 2025

/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 adds support for default values in schema inference, which is a valuable addition. My review focuses on a few key areas for improvement. There's an incorrect assumption about BigQuery's constraints on default values for NUMERIC types, which has led to an incorrect check and a flawed test case. The new test for *big.Rat also exposes a pre-existing issue where this type is not handled correctly during schema inference. Additionally, the PR is missing positive test cases to validate that the new default value feature works as expected for supported types. Finally, I've suggested a small refactoring to improve the clarity of the tag parsing logic. Addressing these points will make the feature more robust and correct.

@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 introduces support for default values in schema inference, which is a valuable addition. The implementation is solid, but I've identified a critical bug where default values are not correctly handled for standard integer types. Additionally, I've noticed that a test for tag parsing errors was removed, which reduces test coverage. I've also included a suggestion to simplify a part of the new logic. Please see the detailed comments below.

@lperson lperson force-pushed the feature/infer-defaults branch from a7adee7 to 1ef1e78 Compare December 1, 2025 00:15
@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 introduces support for default values in BigQuery schema inference, which is a great feature enhancement. The implementation is solid and includes comprehensive tests for both success and failure scenarios. I've identified one bug where default values for standard integer types are not being applied, and a small opportunity to simplify the tag parsing logic. Overall, this is a well-executed change.

@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 introduces a valuable feature by adding support for default values in schema inference. The implementation is clean and includes thorough tests. My review includes suggestions to extend this new functionality to INTERVAL and RANGE types for better completeness, along with corresponding test case additions.

@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 introduces support for default value expressions in BigQuery schema inference via struct tags. The changes are well-implemented, including updates to the tag parser, a new function to validate which types can have default values, and modifications to the schema inference logic to populate the DefaultValueExpression field. The accompanying tests are thorough, covering both valid and invalid use cases for the new default tag option. I have one suggestion to improve the logical correctness of schema inference for array types, which I've detailed in a specific comment. Overall, this is a valuable feature enhancement.

@lperson lperson force-pushed the feature/infer-defaults branch from 4f71428 to 8ffad79 Compare December 1, 2025 00:56
@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 adds support for specifying default values for fields during BigQuery schema inference using a default struct tag. The implementation is robust, including validation for supported types, comprehensive unit tests for both valid and invalid usage, and updated documentation. The changes are well-contained and the logic is sound. I have one minor suggestion to improve code clarity and consistency.

lperson and others added 2 commits November 30, 2025 20:03
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 adds support for inferring default values from struct tags for BigQuery schemas. The changes include updating the tag parser, adding logic to handle the default tag option in schema inference, and providing comprehensive documentation and tests. My review has identified a potential issue with handling duplicate default tags on a field, which could lead to unexpected behavior. I've also suggested a refactoring to improve the readability of the new isDefaultable helper function. Overall, the changes are well-implemented and tested.

@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 introduces support for default values in BigQuery schema inference by adding a default struct tag option. The changes are well-implemented, including updates to the tag parser, schema inference logic, and the addition of comprehensive documentation and tests. The code is solid, and I have one suggestion to improve the readability of the isDefaultable function for better long-term maintainability.

@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 adds support for inferring default values for fields from struct tags in InferSchema. The changes include introducing a new default tag option, updating the tag parser to recognize it, and modifying the schema inference logic to handle default value expressions for supported types. The implementation correctly identifies which types are 'defaultable' and adds extensive documentation and test coverage for the new feature, including positive and negative test cases. The overall implementation is solid. I have one suggestion to improve code quality in the test files by reducing duplication.

@lperson
Copy link
Author

lperson commented Dec 1, 2025

/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 introduces support for default values in BigQuery schema inference. The implementation is thorough, adding a new default struct tag option and handling its parsing and validation correctly. The changes include a new isDefaultable helper function to determine which types support default values, and the schema inference logic is updated accordingly. The new feature is well-documented with clear examples, and the accompanying tests are comprehensive, covering various types and error conditions. The code quality is high, and the changes are a valuable addition. Great work!

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.

bigquery: make InferSchema set column defaults

1 participant