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 — feat: make `read_session` optional in `ReadRowsStream.rows()` · Issue #168 · googleapis/python-bigquery-storage

This repository was archived by the owner on Nov 12, 2025. It is now read-only.
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

feat: make read_session optional in ReadRowsStream.rows() #168

Copy link
Copy link
Closed
#228
Closed
feat: make read_session optional in ReadRowsStream.rows()#168
#228
Copy link
Assignees
tswast
Labels
api: bigquerystorageIssues related to the googleapis/python-bigquery-storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@tswast
tswast
opened on Mar 30, 2021
Issue body actions

Is your feature request related to a problem? Please describe.

ReadRowsStream.rows() and other methods that decode the data currently take a ReadSession as a required argument. This is so that it can use the avro/arrow schema to decode the rows.

This is a bit of a pain, especially when workers are on separate processes.

Describe the solution you'd like

#166 adds arrow_schema and avro_schema properties to ReadRowsResponse. These are populated only in the first message of a read stream, but can be cached locally to decode subsequent messages.

To avoid breaking changes, a ReadSession can still be accepted, but it should be optional. Thankfully Python supports arguments which work either as args or kwargs, so I think this does not have to be a breaking change. We need to make sure we comment to the library devs that the order matters for this argument, though.

Describe alternatives you've considered

New Reader class?

Additional context

N/A

Activity

  1. tswast
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Mar 30, 2021
  2. product-auto-label
    added
    api: bigquerystorageIssues related to the googleapis/python-bigquery-storage API.
    on Mar 30, 2021
  3. tswast
    self-assigned this
    on Jul 7, 2021
  4. tswast commented on Jul 7, 2021

    @tswast
    tswast
    on Jul 7, 2021
    ContributorAuthor
    More actions

    Although it's not documented in the Python reference, the source proto has a schema oneof field for this behavior.

    https://github.com/googleapis/googleapis/blob/fe3cc5e650b8e52537f02549fe5fb49fc386f3a9/google/cloud/bigquery/storage/v1/storage.proto#L209-L215

    We should be able to use very similar logic as from_read_session

    python-bigquery-storage/google/cloud/bigquery_storage_v1/reader.py

    Lines 495 to 504 in 8c10713

    def from_read_session(read_session):
    schema_type = read_session._pb.WhichOneof("schema")
    if schema_type == "avro_schema":
    return _AvroStreamParser(read_session)
    elif schema_type == "arrow_schema":
    return _ArrowStreamParser(read_session)
    else:
    raise TypeError(
    "Unsupported schema type in read_session: {0}".format(schema_type)
    )

  5. tswast commented on Jul 8, 2021

    @tswast
    tswast
    on Jul 8, 2021
    ContributorAuthor
    More actions

    Behavior change: Can't raise ImportError if necessary libraries aren't installed until iteration time because without read_session, we don't know the serialization format until the first ReadRowsResponse message is parsed.

  6. tswast commented on Jul 8, 2021

    @tswast
    tswast
    on Jul 8, 2021
    ContributorAuthor
    More actions

    Behavior change: Empty stream returns dataframe / arrow table with no columns because schema is not available.

    Edit: Since this is a breaking change, maybe we actually do still parse read_session for this? We can still deprecate read_session but wait to remove all parsing code until next major version?

  7. tswast
    closed this as completedin #228on Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tswast
    tswast

Labels

api: bigquerystorageIssues related to the googleapis/python-bigquery-storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

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.