Skip to content

Conversation

@sahilkumarsingh
Copy link
Contributor

Description

This PR addresses the issue #1456

Documents the schema preservation behaviour when using SaveMode.Overwrite, which was updated somewhere between 0.22.2 and 0.41.0 versions.

Changes

  • Added "Schema Behaviour on Overwrite" section to README-template.md
  • Explains that the existing table schema is preserved during overwrites
  • Documents workarounds for intentional schema changes

Why

Users upgrading from versions prior to 0.41.0 encounter unexpected failures when overwriting tables with different column types. This documentation helps users understand the expected behaviour and provides workarounds.

@google-cla
Copy link

google-cla bot commented Jan 10, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sahilkumarsingh, 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 enhances the documentation for the Spark-BigQuery connector by providing crucial information regarding the schema preservation behavior when using SaveMode.Overwrite. The update aims to address user confusion and unexpected failures encountered when upgrading the connector, particularly when attempting to overwrite tables with differing schemas. By clearly outlining the connector's behavior and offering explicit workarounds for intentional schema changes, this PR ensures users can better understand and manage their data operations, preventing accidental data type changes and improving the overall user experience.

Highlights

  • Documentation Update: A new section titled 'Schema Behavior on Overwrite' has been added to README-template.md to clarify how the Spark-BigQuery connector handles schema during overwrite operations.
  • Schema Preservation: The documentation now explicitly states that when using SaveMode.Overwrite, the connector preserves the existing BigQuery table's schema, retaining column types, descriptions, and policy tags, while only truncating the data.
  • Handling Schema Mismatches: It is documented that writes will fail if the DataFrame's schema differs from the existing table's schema (e.g., changing a column type). Workarounds are provided: either drop the table before overwriting or use BigQuery DDL to alter the schema first.
  • Behavior Context: The documentation explains that this schema preservation behavior was introduced between versions 0.22.0 and 0.41.0 to prevent accidental schema drift and applies to both indirect and direct write methods.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 adds important documentation about the schema preservation behavior when using SaveMode.Overwrite. The new section clearly explains that the existing schema is retained, which can be a source of confusion for users upgrading from older versions. The provided workarounds for intentional schema changes are helpful. My review includes a minor suggestion to ensure the version numbers mentioned are accurate, aligning with the information in the PR description.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sahilkumarsingh
Copy link
Contributor Author

cc: @davidrabinowitz

@sahilkumarsingh
Copy link
Contributor Author

cc: @yalimu-g

`INTEGER` to `DOUBLE`), the write will fail with a type mismatch error. To change the schema, either:
- Drop the table before overwriting
- Use BigQuery DDL to alter the table schema first

Copy link
Contributor

Choose a reason for hiding this comment

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

For some of the schema difference the following options can work with overwrite:
Programmatic Relaxation: Set .option("allowFieldRelaxation", "true") for nullability changes and .option("allowFieldAddition", "true") for new columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can add this detail. Shall I add it?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, please check.

@yalimu-g
Copy link
Contributor

/gcbrun

@yalimu-g
Copy link
Contributor

/gcbrun

@sahilkumarsingh
Copy link
Contributor Author

looks like a CI infrastructure test issue

@yalimu-g
Copy link
Contributor

/gcbrun

@yalimu-g yalimu-g merged commit c66234f into GoogleCloudDataproc:master Jan 23, 2026
5 checks passed
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.

2 participants