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 — fix: empty record dtypes by yokomotod · Pull Request #2147 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@yokomotod

@yokomotod yokomotod commented Mar 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #2148 🦕

Can we increase the minimum supported pandas from 1.1.4 to 1.3.0 ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@yokomotod
fix: empty record dtypes
37dab9d
@product-auto-label product-auto-label Bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery API. labels Mar 19, 2025
@yokomotod
yokomotod marked this pull request as ready for review March 19, 2025 07:11
@yokomotod
yokomotod requested review from a team and agrawal-siddharth March 19, 2025 07:11
@blunderbuss-gcf blunderbuss-gcf Bot assigned Linchin Mar 19, 2025
@yokomotod
yokomotod marked this pull request as draft March 19, 2025 07:11
@yokomotod
update pandas minimum version
78151f1
yokomotod
yokomotod commented Mar 19, 2025
View reviewed changes
Comment thread google/cloud/bigquery/table.py
Comment on lines -2672 to -2674
# Avoid "ValueError: need at least one array to concatenate" on
# older versions of pandas when converting empty RecordBatch to
# DataFrame. See: https://github.com/pandas-dev/pandas/issues/41241

@yokomotod yokomotod Mar 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

pandas-dev/pandas#41052 has released with pandas 1.3.0 (as mentioned in above issue: pandas-dev/pandas#41241 (comment))

So if we can increase minimum pandas version to 1.3.0, we don't need this workaround

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tswast tswast Mar 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We should really come up with a consistent policy across all Google packages:

  • pandas-gbq supports 1.1.4+ (https://github.com/googleapis/python-bigquery-pandas/blob/b3a9af27960c6e2736835d6a94e116f550f94114/setup.py#L27)
  • db-dtypes supports 1.2.0+ (https://github.com/googleapis/python-db-dtypes-pandas/blob/44a5aa24ef3219849e9e0bedeeaebc4b9ee53d9e/setup.py#L34)
  • bigframes supports 1.5.3+ (https://github.com/googleapis/python-bigquery-dataframes/blob/7d00be67cf50fdf713c40912f207d14f0f65538f/setup.py#L53)
  • Colab and BigQuery Studio Python notebooks are both in the 2.x range now.

CC @chalmerlowe @Linchin @shollyman @parthea

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Linchin Linchin Mar 26, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Indeed, moving to a monorepo might help make the dependencies more consistent, ideally we might want any overlapped dependencies among the handwritten BigQuery projects to be consistent.

But just for the purpose of this PR, I think it's reasonable to increase the minimum pandas version to 1.3.0, as long as it's not breaking anything.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yokomotod reacted with heart emoji
All reactions
  • ❤️ 1 reaction
yokomotod
yokomotod commented Mar 19, 2025
View reviewed changes
Comment thread testing/constraints-3.9.txt
opentelemetry-instrumentation==0.20b0
opentelemetry-sdk==1.1.0
packaging==24.2.0
pandas==1.1.4

@yokomotod yokomotod Mar 19, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I confirmed that pandas==1.2.5 reproduces

FAILED tests/unit/test_table.py::TestRowIterator::test_to_dataframe_w_bqstorage_no_streams - ValueError: need at least one array to concatenate

and pandas==1.3.0 can pass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Linchin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@tswast tswast Mar 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for updating the constraint file!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Linchin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@yokomotod
yokomotod marked this pull request as ready for review March 19, 2025 15:15
tswast
tswast reviewed Mar 20, 2025
View reviewed changes

@tswast tswast left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This looks good to me, but will wait for @chalmerlowe or @Linchin to approve.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/bigquery/table.py
Comment on lines -2672 to -2674
# Avoid "ValueError: need at least one array to concatenate" on
# older versions of pandas when converting empty RecordBatch to
# DataFrame. See: https://github.com/pandas-dev/pandas/issues/41241

@tswast tswast Mar 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We should really come up with a consistent policy across all Google packages:

  • pandas-gbq supports 1.1.4+ (https://github.com/googleapis/python-bigquery-pandas/blob/b3a9af27960c6e2736835d6a94e116f550f94114/setup.py#L27)
  • db-dtypes supports 1.2.0+ (https://github.com/googleapis/python-db-dtypes-pandas/blob/44a5aa24ef3219849e9e0bedeeaebc4b9ee53d9e/setup.py#L34)
  • bigframes supports 1.5.3+ (https://github.com/googleapis/python-bigquery-dataframes/blob/7d00be67cf50fdf713c40912f207d14f0f65538f/setup.py#L53)
  • Colab and BigQuery Studio Python notebooks are both in the 2.x range now.

CC @chalmerlowe @Linchin @shollyman @parthea

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread testing/constraints-3.9.txt
opentelemetry-instrumentation==0.20b0
opentelemetry-sdk==1.1.0
packaging==24.2.0
pandas==1.1.4

@tswast tswast Mar 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for updating the constraint file!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Linchin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Linchin Linchin added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Mar 26, 2025
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Mar 26, 2025
@Linchin
Merge branch 'main' into fix-empty-dtypes
a27b392
@Linchin Linchin added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Mar 26, 2025
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Mar 26, 2025
@Linchin

Linchin commented Mar 27, 2025

Copy link
Copy Markdown
Contributor

I think we need to remove some liens in the unit test so coverage test can pass, could you fix it for us? Then we should be able to merge the PR

Name                                                         Stmts   Miss Branch BrPart  Cover   Missing
--------------------------------------------------------------------------------------------------------
tests/unit/test_table.py                                      3288      2     86      1    99%   4152-4153
yokomotod reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yokomotod added 2 commits March 28, 2025 04:16
@yokomotod
Merge branch 'main' into fix-empty-dtypes
d6ce8c1
@yokomotod
fix coverage
ffd6e42
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Mar 27, 2025
@yokomotod

yokomotod commented Mar 27, 2025

Copy link
Copy Markdown
Contributor Author

@Linchin done ffd6e42

Indeed, pandas>=1.3.0 must have Float64Dtype

https://pandas.pydata.org/pandas-docs/stable/whatsnew/v1.2.0.html#experimental-nullable-data-types-for-float-data

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Linchin Linchin added the kokoro:run Add this label to force Kokoro to re-run the tests. label Mar 31, 2025
@Linchin Linchin added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 31, 2025
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Mar 31, 2025
@Linchin

Linchin commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

A different system test is failing, could you fix it too? Thanks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yokomotod
fix test_pandas
9f2b0ef
yokomotod
yokomotod commented Apr 1, 2025
View reviewed changes
Comment thread tests/system/test_pandas.py
Comment on lines -1225 to -1230
# Result is dependent upon which version of pandas is being used.
# Float64 was not introduced until pandas version 1.4.
if PANDAS_INSTALLED_VERSION >= "1.4":
assert df.dtypes["float64_col"].name == "Float64"
else:
assert df.dtypes["float64_col"].name == "string"

@yokomotod yokomotod Apr 1, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Float64 is introduced in pandas 1.2.0, not 1.4. So we can drop this handling now (pandas >= 1.3.0)

https://btx.cloud.google.com/invocations/feb3ac69-f2db-449c-ab07-2122420f069b/targets/cloud-devrel%2Fclient-libraries%2Fpython%2Fgoogleapis%2Fpython-bigquery%2Fpresubmit%2Fsystem-3.9/log

nox > python -m pip freeze
  .
  .
  .
pandas==1.3.0
  .
  .
  .

        if PANDAS_INSTALLED_VERSION >= "1.4":
            assert df.dtypes["float64_col"].name == "Float64"
        else:
>           assert df.dtypes["float64_col"].name == "string"
E           AssertionError: assert 'Float64' == 'string'
E             
E             - string
E             + Float64

https://pandas.pydata.org/pandas-docs/stable/whatsnew/v1.2.0.html#experimental-nullable-data-types-for-float-data

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@yokomotod
Merge branch 'main' into fix-empty-dtypes
bb8cd0b
@yokomotod

yokomotod commented Apr 1, 2025

Copy link
Copy Markdown
Contributor Author

@Linchin sorry to overlooking another error, I fixed it too.

Can you try to run Ci test again ?

I have trouble to run the system test on my local (maybe due to old numpy on apple silicon) but the tests should pass.

Linchin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Linchin Linchin added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 1, 2025
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 1, 2025
Linchin
Linchin approved these changes Apr 1, 2025
View reviewed changes

@Linchin Linchin left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Linchin
Linchin merged commit 77d7173 into googleapis:main Apr 1, 2025
@release-please release-please Bot mentioned this pull request Apr 1, 2025
chore(main): release 3.32.0 #2152
Merged
This was referenced May 20, 2025
May 19, 2025 kitta65/bq-extension-vscode#764
Closed
May 19, 2025 kitta65/prettier-plugin-bq#656
Closed
May 19, 2025 kitta65/bq2cst#515
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@agrawal-siddharth agrawal-siddharth Awaiting requested review from agrawal-siddharth
2 more reviewers
@tswast tswast tswast left review comments
@Linchin Linchin Linchin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Linchin Linchin

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

object dtype when empty query result

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@yokomotod @Linchin @tswast @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.