[components] Standardize duckdb table width when generating CLI snippet output #27997
+57
−8
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.
Summary & Motivation
Standardize output width for duckdb commands in docs snippets. We do this by executing them in a pseudoterminal using
pexpect
and setting duckdb's.maxwidth
setting.DuckDB's
.maxwidth
setting is extremely finicky and annoying. It is often silently ignored. The only way I could get it to reliably actuate was when running interactively from the command line. It seems to change it's behavior based on the kind of output stream it's hooked up to.The solution here is unfortunately complex, but so far as I can tell there is no way at all to get
duckdb
to respect.maxwidth
outside of a terminal environment. I tried using an-init
script and many other things. It just silently ignores.maxwidth
unless you are in a terminal. So we simulate a terminal withpexpect
, which works. This same approach may prove useful in the future for other CLIs that try to detect a terminal.How I Tested These Changes
Regenerated snippets locally, no changes-- previously it would generate a longer duckdb table than would be generated in CI.