Sitelet https://github.com/googleapis/python-spanner/issues/1316
Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Decode metadata and values of PartialResultSet #1316

Description

@xxntti3n

Hello everyone,
I am reading the change stream from Spanner using the Spanner client. I attempted to use StreamedResultSet, but I'm having trouble resolving it. Could someone please help me with mapping the metadata and values from the results when I run execute_streaming_sql? Thank you!
request = spanner_v1.ExecuteSqlRequest( session=session.name, sql=f"SELECT * FROM READ_spanner_all_change_stream( start_timestamp => '{current_time}', end_timestamp => NULL, partition_token => NULL, heartbeat_milliseconds => 10000)", ) result_set = spanner_client.execute_streaming_sql(request=request)

Activity

  1. olavloite commented on Apr 3, 2025

    @olavloite
    Contributor

    @xxntti3n It is highly recommended that you just use the standard query functions in the client library. These already use the execute_streaming_sql RPC under the hood and hide the details of mapping the returned PartialResultSets and metadata into easy-to-consume objects. So just follow this example:

    with database.snapshot() as snapshot:

    Note that if you specifically want to access the underlying protobuf values instead of having them converted to Python types, then you can set the lazy_decoding argument like this:

      with database.snapshot() as snapshot:
          results = snapshot.execute_sql(
              "SELECT SingerId, AlbumId, AlbumTitle FROM Albums",
              lazy_decode=True
          )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions