dariocurr opened a new pull request, #23797:
URL: https://github.com/apache/datafusion/pull/23797
## Which issue does this PR close?
- Closes #23796.
## 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 `.history` file with no way to point it somewhere else.
## What changes are included in this PR?
- Add a `--history-file <PATH>` CLI flag to `datafusion-cli`, validated at
parse time (rejects a path that is an existing directory, or whose parent
directory doesn't exist).
- Add a `DATAFUSION_HISTORY_FILE` environment variable as an alternative way
to set it (e.g. for scripted/containerized setups). The `--history-file`
flag takes precedence over the environment variable.
- The existing default behavior (`.history`, relative to the current
directory) is unchanged when neither is set, so this is non-breaking.
- `exec_from_repl` now takes `history_file: Option<&Path>` instead of
hardcoding `.history` twice; the `.history` default now lives in one place
inside `exec_from_repl` itself.
- Updated `datafusion-cli/examples/cli-session-context.rs` (the only other
caller of `exec_from_repl`) and `docs/source/user-guide/cli/usage.md`
accordingly.
## 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_dir` helpers, which aren't
separately unit-tested either). I manually verified end-to-end via the built
binary:
- Default (`.history` in cwd, unchanged behavior)
- `--history-file <path>` override
- `DATAFUSION_HISTORY_FILE=<path>` override
- `--history-file` taking precedence over `DATAFUSION_HISTORY_FILE` when
both are set
- `--history-file` pointing at a non-existent parent directory fails fast
with a clear error instead of a late rustyline error
Existing `datafusion-cli` unit tests pass (`cargo test -p datafusion-cli
--lib --bins`).
## Are there any user-facing changes?
Yes: a new `--history-file` CLI flag and `DATAFUSION_HISTORY_FILE`
environment variable, documented in `docs/source/user-guide/cli/usage.md`.
No breaking changes; default behavior is unchanged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]