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

add FROM to InitialKeywords vector in autocomplete extension #9877

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions extension/autocomplete/autocomplete_extension.cpp
Expand Up @@ -82,15 +82,15 @@ static vector<string> InitialKeywords() {
return vector<string> {"SELECT", "INSERT", "DELETE", "UPDATE", "CREATE", "DROP", "COPY",
"ALTER", "WITH", "EXPORT", "BEGIN", "VACUUM", "PREPARE", "EXECUTE",
"DEALLOCATE", "CALL", "ANALYZE", "EXPLAIN", "DESCRIBE", "SUMMARIZE", "LOAD",
"CHECKPOINT", "ROLLBACK", "COMMIT", "CALL"};
"CHECKPOINT", "ROLLBACK", "COMMIT", "CALL", "FROM"};
}

static vector<AutoCompleteCandidate> SuggestKeyword(ClientContext &context) {
auto keywords = InitialKeywords();
vector<AutoCompleteCandidate> result;
for (auto &kw : keywords) {
auto score = 0;
if (kw == "SELECT" || kw == "DELETE" || kw == "INSERT" || kw == "UPDATE") {
if (kw == "FROM" || kw == "SELECT" || kw == "DELETE" || kw == "INSERT" || kw == "UPDATE") {
score = 1;
}
result.emplace_back(kw + " ", score);
Expand Down
8 changes: 8 additions & 0 deletions tools/shell/tests/test_autocomplete.py
Expand Up @@ -17,6 +17,14 @@ def test_autocomplete_select(shell, autocomplete_extension):
result = test.run()
result.check_stdout('SELECT')

def test_autocomplete_first_from(shell, autocomplete_extension):
test = (
ShellTest(shell)
.statement("CALL sql_auto_complete('FRO')")
)
result = test.run()
result.check_stdout('FROM')

def test_autocomplete_column(shell, autocomplete_extension):
test = (
ShellTest(shell)
Expand Down