这是indexloc提供的服务,不要输入任何密码
Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions internal/interactive/interactive_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ func (c *InteractiveClient) queryCompleter(d prompt.Document) []prompt.Suggest {
case isFirstWord(text):
suggestions := c.getFirstWordSuggestions(text)
s = append(s, suggestions...)
case isDuckDbMetaQuery(text):
tableSuggestions := c.getTableSuggestions(lastWord(text))
s = append(s, tableSuggestions...)
case metaquery.IsMetaQuery(text):
suggestions := metaquery.Complete(&metaquery.CompleterInput{
Query: text,
Expand All @@ -497,8 +500,15 @@ func (c *InteractiveClient) getFirstWordSuggestions(word string) []prompt.Sugges

var s []prompt.Suggest
// add all we know that can be the first words
// "select", "with"
s = append(s, prompt.Suggest{Text: "select", Output: "select"}, prompt.Suggest{Text: "with", Output: "with"})
// "select", "with", "describe", "show", "summarize"
s = append(s,
prompt.Suggest{Text: "select", Output: "select"},
prompt.Suggest{Text: "with", Output: "with"},
prompt.Suggest{Text: "describe", Output: "describe"},
prompt.Suggest{Text: "show", Output: "show"},
prompt.Suggest{Text: "summarize", Output: "summarize"},
prompt.Suggest{Text: "explain", Output: "explain"},
)
// metaqueries
s = append(s, metaquery.PromptSuggestions()...)
return s
Expand Down
15 changes: 15 additions & 0 deletions internal/interactive/interactive_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ func lastWord(text string) string {
return text[strings.LastIndex(text, " "):]
}

// isDuckDbMetaQuery returns true if the input string equals 'describe', 'show', or 'summarize'
func isDuckDbMetaQuery(s string) bool {
ts := strings.ToLower(strings.TrimSpace(s))
switch {
case ts == "describe":
return true
case ts == "show":
return true
case ts == "summarize":
return true
default:
return false
}
}

//
// keeping this around because we may need
// to revisit exit on non-darwin platforms.
Expand Down