docs: fix undefined variable in schema evolution transaction example#3607
Open
anxkhn wants to merge 1 commit into
Open
docs: fix undefined variable in schema evolution transaction example#3607anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
The schema-evolution-in-a-transaction example bound the inner context manager as update_schema but called update.add_column(...), where update is undefined in that scope (it is left over from the preceding standalone example). Copy-pasting the snippet raised NameError. Use the bound name update_schema, matching the create_table_transaction example above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale for this change
The "schema evolution" section of the Python API docs shows how to evolve a
schema inside a transaction:
The inner context manager is bound as
update_schema, but the body callsupdate.add_column(...). The nameupdateis not defined in that scope; it isleft over from the preceding standalone example just above it
(
with table.update_schema() as update:). Copy-pasting the transaction snippetverbatim raises
NameError: name 'update' is not defined.This changes the call to use the bound name
update_schema, so the documentedexample runs as written. It also matches the already-correct
create_table_transactionexample earlier in the same page, which usesupdate_schema.add_column(...).Are these changes tested?
No automated test: this is a one-line documentation fix with no code change. I
verified it manually against the public API:
Transaction.update_schema()returns an
UpdateSchemacontext manager whoseadd_column(path, field_type, doc=None, ...)signature matches the positional call in the example, so thecorrected snippet executes without error.
pre-commit(markdownlint, codespell,trailing-whitespace/end-of-file) passes on the changed file.
Are there any user-facing changes?
No. Documentation only; there are no changes to library behavior or public API.