GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `DataFrame.to_gbq` with `if_exists="replace"` and `clustering_columns` can swap data between columns if order is different · Issue #2502 · google/bigframes

DataFrame.to_gbq with if_exists="replace" and clustering_columns can swap data between columns if order is different #2502

New issue
Copy link
New issue
Copy link
Closed
#2532
Closed
DataFrame.to_gbq with if_exists="replace" and clustering_columns can swap data between columns if order is different#2502
#2532
Copy link
Assignees
chelsea-linjialuoo
Labels
api: bigqueryIssues related to the googleapis/python-bigquery-dataframes API.

Description

@jbandoro
jbandoro
opened on Mar 10, 2026
Issue body actions

Environment details

Python: 3.12.10 (main, Apr  9 2025, 03:49:38) [Clang 20.1.0 ]
bigframes==2.37.0
google-cloud-bigquery==3.40.1
pandas==3.0.1
pyarrow==23.0.1

Steps to reproduce

  1. Create a table with Dataframe.to_gbq with clustering_columns
  2. Reorder the clustering column and another column that has the same type
  3. Write the updated dataframe to the same table with if_exists="replace"
  4. Inspect the table to see columns with different data than in dataframe

Code example

import bigframes.pandas as bpd
import pandas as pd

TABLE_ID = "my_project.my_dataset.test_table"

df = pd.DataFrame(
    {"a": [10, 1, 2], "b": ["Justin", "Alex", "Jim"], "c": ["cat", "dog", "cat"]}
)
bdf = bpd.DataFrame(df)

# First time writing, all good
bdf.to_gbq(TABLE_ID, clustering_columns=["b"])

# Reorder the clustered column b and column c
bdf = bdf[["a", "c", "b"]]

# When replacing and writing, the b and c columns are swapped
bdf.to_gbq(TABLE_ID, if_exists="replace", clustering_columns=["b"])

While the dataframe looks good, the updated table now has columns b/c data swapped:

Image Image

This doesn't happen if clustering_columns is not used in my testing.

Reacted by Chelsea Lin

Activity

  1. product-auto-label
    added
    api: bigqueryIssues related to the googleapis/python-bigquery-dataframes API.
    on Mar 10, 2026
  2. blunderbuss-gcf
    assigned
    jialuoo
    on Mar 10, 2026
  3. chelsea-lin
    self-assigned this
    on Mar 24, 2026
  4. chelsea-lin
    added a commit that references this issue on Mar 26, 2026

    fix: to_gbq may swap data columns when replace table (#2532)

    17ecc65
  5. chelsea-lin
    closed this as completedin #2532on Mar 26, 2026
  6. chelsea-lin commented on Mar 26, 2026

    @chelsea-lin
    chelsea-lin
    on Mar 26, 2026
    Contributor
    More actions

    Hi @jbandoro, thank you for reporting this. We expect a fix to be included in our next release, likely coming out next week. Please let us know if you have any further questions. Thanks!

    Reacted by Justin Bandoro
  7. chalmerlowe
    added a commit that references this issue on Mar 31, 2026

    fix: to_gbq may swap data columns when replace table (#2532)

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

Metadata

Metadata

Assignees

  • @chelsea-lin
    chelsea-lin
  • @jialuoo
    jialuoo

Labels

api: bigqueryIssues related to the googleapis/python-bigquery-dataframes API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.