feat: allow configuring datafusion-cli history file location#23797
Open
dariocurr wants to merge 1 commit into
Open
feat: allow configuring datafusion-cli history file location#23797dariocurr wants to merge 1 commit into
dariocurr wants to merge 1 commit into
Conversation
datafusion-cli hardcoded the interactive shell's rustyline history as the relative path `.history`, so every launch directory silently got its own history file with no way to point it elsewhere. Add a `--history-file <PATH>` flag and a `DATAFUSION_HISTORY_FILE` environment variable (flag takes precedence), keeping `.history` as the default so existing behavior is unchanged. Closes apache#23796.
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
Contributor
Author
|
Re the cargo-semver-checks note above: this is an expected, intentional minor breaking change. Per the API health policy, could a committer add the |
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?
Rationale for this change
datafusion-cli's interactive REPL hardcodes its rustyline history file as the relative path.history. Because the path is relative, the history file is created (and looked up) in whatever directory the CLI happens to be launched from, so every working directory silently accumulates its own hidden.historyfile with no way to point it somewhere else.What changes are included in this PR?
--history-file <PATH>CLI flag todatafusion-cli, validated at parse time (rejects a path that is an existing directory, or whose parent directory doesn't exist).DATAFUSION_HISTORY_FILEenvironment variable as an alternative way to set it (e.g. for scripted/containerized setups). The--history-fileflag takes precedence over the environment variable..history, relative to the current directory) is unchanged when neither is set, so this is non-breaking.exec_from_replnow takeshistory_file: Option<&Path>instead of hardcoding.historytwice; the.historydefault now lives in one place insideexec_from_replitself.datafusion-cli/examples/cli-session-context.rs(the only other caller ofexec_from_repl) anddocs/source/user-guide/cli/usage.mdaccordingly.Are these changes tested?
This is a small, mostly mechanical CLI argument-plumbing change with no new branching logic worth unit-testing in isolation (the added validator mirrors the existing
parse_valid_file/parse_valid_data_dirhelpers, which aren't separately unit-tested either). I manually verified end-to-end via the built binary:.historyin cwd, unchanged behavior)--history-file <path>overrideDATAFUSION_HISTORY_FILE=<path>override--history-filetaking precedence overDATAFUSION_HISTORY_FILEwhen both are set--history-filepointing at a non-existent parent directory fails fast with a clear error instead of a late rustyline errorExisting
datafusion-cliunit tests pass (cargo test -p datafusion-cli --lib --bins).Are there any user-facing changes?
Yes: a new
--history-fileCLI flag andDATAFUSION_HISTORY_FILEenvironment variable, documented indocs/source/user-guide/cli/usage.md. No breaking changes; default behavior is unchanged.