Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix history file usage in SQL CLI tool. #155

Merged
merged 2 commits into from
Nov 15, 2022

Conversation

Yury-Fridlyand
Copy link

@Yury-Fridlyand Yury-Fridlyand commented Nov 4, 2022

Signed-off-by: Yury-Fridlyand yuryf@bitquilltech.com

Description

Changes include:

  • Fix usage of FileHistory.
  • Fix reading history_file and log_file parameters from config.
  • Fix interpreting the default or custom user value.

Config location: ~/.config/opensearchsql-cli/config
Default location for saving history and log files: ~/.config/opensearchsql-cli
Inspired by: https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/examples/prompts/history/persistent-history.py

Test

  1. Run SQL CLI in venv (see instructions below)
  2. Run a query
  3. Exit from SQL CLI
  4. Open it back
  5. Hit arrow-up keyboard button

How to test

Ref: https://github.com/opensearch-project/sql/blob/2.x/sql-cli/development_guide.md#development-environment-set-up

Do once:

cd sql-cli
pip install virtualenv
virtualenv venv
pip install --editable .

Then every time you want to debug SQL CLI:

<checkout>
cd sql-cli
source ./venv/bin/activate

To exit from venv:

deactivate

You can run SQL CLI and switch branch. It will keep working with given timeout until closed.

Issues Resolved

Query history didn't persist across SQL CLI runs.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Nov 4, 2022

Codecov Report

Merging #155 (f264759) into integ-cli-history-fix (8c91689) will decrease coverage by 2.56%.
The diff coverage is 100.00%.

@@                     Coverage Diff                     @@
##             integ-cli-history-fix     #155      +/-   ##
===========================================================
- Coverage                    98.27%   95.71%   -2.57%     
- Complexity                    3344     3351       +7     
===========================================================
  Files                          326      337      +11     
  Lines                         8443     9115     +672     
  Branches                       553      672     +119     
===========================================================
+ Hits                          8297     8724     +427     
- Misses                         142      334     +192     
- Partials                         4       57      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.27% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rch/sql/planner/physical/catalog/CatalogTable.java 100.00% <ø> (ø)
...us/storage/model/PrometheusResponseFieldNames.java 100.00% <ø> (ø)
...rg/opensearch/sql/analysis/ExpressionAnalyzer.java 100.00% <100.00%> (ø)
...c/main/java/org/opensearch/sql/expression/DSL.java 100.00% <100.00%> (ø)
...java/org/opensearch/sql/expression/Expression.java 100.00% <100.00%> (ø)
...rch/sql/expression/aggregation/TakeAggregator.java 100.00% <100.00%> (ø)
...pensearch/sql/expression/parse/GrokExpression.java 100.00% <100.00%> (ø)
...ensearch/sql/expression/parse/ParseExpression.java 100.00% <100.00%> (ø)
...earch/sql/expression/parse/PatternsExpression.java 100.00% <100.00%> (ø)
...ensearch/sql/expression/parse/RegexExpression.java 100.00% <100.00%> (ø)
... and 26 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand merged commit 5aa0cdc into integ-cli-history-fix Nov 15, 2022
@Yury-Fridlyand Yury-Fridlyand deleted the dev-cli-history-fix branch November 15, 2022 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants