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: completion item for limit node #193

Merged
merged 1 commit into from
Dec 15, 2024
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
6 changes: 6 additions & 0 deletions langserver/internal/source/completion/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ func (c *completor) getMostNarrowInputScanNode(node rast.ScanNode, termOffset in
return n, true
}
return nil, false
case *rast.LimitOffsetScanNode:
node, ok := c.getMostNarrowInputScanNode(n.InputScan(), termOffset)
if ok {
return node, true
}
return nil, false
default:
c.logger.Printf("unknown scan node type: %T\n", n)
return nil, false
Expand Down
27 changes: 27 additions & 0 deletions langserver/internal/source/completion/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,33 @@ func TestProject_CompleteColumns(t *testing.T) {
},
},
},
"Complete column on limit clause": {
files: map[string]string{
"file1.sql": "SELECT | FROM `project.dataset.table` LIMIT 10",
},
bqTableMetadataMap: map[string]*bq.TableMetadata{
"project.dataset.table": {
Schema: bq.Schema{
{
Name: "id",
Description: "id description",
Type: bq.IntegerFieldType,
},
},
},
},
expectCompletionItems: []CompletionItem{
{
Kind: lsp.CIKField,
NewText: "id",
Documentation: lsp.MarkupContent{
Kind: lsp.MKPlainText,
Value: "INTEGER\nid description",
},
TypedPrefix: "",
},
},
},
}

for n, tt := range tests {
Expand Down
Loading