Skip to content

object dtype when empty query result #2148

@yokomotod

Description

@yokomotod

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version:
  • Python version: python --version: Python 3.13.2
  • pip version: pip --version: pip 25.0
  • google-cloud-bigquery version: pip show google-cloud-bigquery: 3.30.0

Steps to reproduce

>>> from google.cloud import bigquery

>>> bigquery.Client().query("SELECT * FROM (SELECT 1 as integer_field) WHERE 1 = 0").result().to_dataframe().dtypes
integer_field    object
dtype: object


>>> bigquery.Client().query("SELECT * FROM (SELECT 1 as integer_field) WHERE 1 = 1").result().to_dataframe().dtypes
integer_field    Int64
dtype: object

It uses subquery SELECT 1 as integer_field to skip table setup, but it's same on normal query from tables.

cause

https://github.com/googleapis/python-bigquery/blob/v3.30.0/google/cloud/bigquery/table.py#L2642

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions