docs: Add docstring examples to the unparser module - #1692
Draft
ting-hong-shieh wants to merge 1 commit into
Draft
docs: Add docstring examples to the unparser module#1692ting-hong-shieh wants to merge 1 commit into
ting-hong-shieh wants to merge 1 commit into
Conversation
Every public function in `Dialect` and `Unparser` lacked the usage example required by AGENTS.md. Each now carries a doctest built on the same input table, so the examples run under pytest's --doctest-modules. The examples show what actually differs between dialects: the default dialect leaves identifiers unquoted, MySQL and SQLite quote with backticks, PostgreSQL and DuckDB quote with double quotes. Also correct the `Dialect` class summary, which described it as "DataFusion data catalog", and describe what `with_pretty` does rather than restating its name.
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.
Which issue does this PR close?
Closes #1691.
Rationale for this change
AGENTS.mdrequires every public Python function to carry a usage example, andno public function in
python/datafusion/unparser.pyhad one. The omission ismost costly in this module: the reason
Dialectexists is that dialects renderthe same plan differently, and nothing in the documentation showed that.
What changes are included in this PR?
Docstring examples for
Dialect.default,Dialect.mysql,Dialect.postgres,Dialect.sqlite,Dialect.duckdb,Unparser.plan_to_sqlandUnparser.with_pretty. All build the same input table so the examples differonly in the behaviour being demonstrated, and each shows the actual quoting a
dialect produces:
Corrected the
Dialectclass summary, which read"DataFusion data catalog."Described what
with_prettydoes — it drops redundant parentheses and returnsthe same unparser so the call can be chained — instead of restating its name.
No behaviour is changed; the diff is docstrings only.
Are there any user-facing changes?
Documentation only. The new examples run as doctests under the existing
--doctest-modulessetting, so they are checked in CI.