Skip to content

Commit

Permalink
fix: Swap writer and reader schema to correct places in sample (#1052)
Browse files Browse the repository at this point in the history
* samples: schema evolution

* Add command-line commands

* Fix tag for rollback

* Make formatting fixes

* Formatting fixes

* Fix exceptions

* fix: Set x-goog-request-params for streaming pull request

* Set blunderbuss config to auto-assign issues and PRs

* fix: Swap writer and reader schema to correct places in sample
  • Loading branch information
kamalaboulhosn committed Dec 15, 2023
1 parent 062c132 commit 265f410
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/snippets/schema.py
Expand Up @@ -645,7 +645,7 @@ def subscribe_with_avro_schema_with_revisions(
subscription_path = subscriber.subscription_path(project_id, subscription_id)

with open(avsc_file, "rb") as file:
writer_avro_schema = schema.parse(file.read())
reader_avro_schema = schema.parse(file.read())
# Dict to keep readers for different schema revisions.
revisions_to_readers = {}

Expand All @@ -665,7 +665,7 @@ def callback(message: pubsub_v1.subscriber.message.Message) -> None:
print(f"{schema_path} not found.")
message.nack()
return
reader_avro_schema = schema.parse(received_avro_schema.definition)
writer_avro_schema = schema.parse(received_avro_schema.definition)
revisions_to_readers[schema_revision_id] = DatumReader(
writer_avro_schema, reader_avro_schema
)
Expand Down

0 comments on commit 265f410

Please sign in to comment.