Skip to content

Commit

Permalink
Merge pull request #193 from kitagry/completion-for-limit
Browse files Browse the repository at this point in the history
fix: completion item for limit node
  • Loading branch information
kitagry authored Dec 15, 2024
2 parents 560f734 + 38d3f5f commit 3cf78dd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
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

0 comments on commit 3cf78dd

Please sign in to comment.