-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Provide autocompletions for dbt models * Provide autocompletions for dbt sources * Provide autocompletions for dbt macros * Provide all available sources in completion requests * Show package name in source completion suggestions * Simplify macros definition search * Simplify dbt autocompletion interface * Remove unused params * Provide extended autocompletions for dbt models * Refactoring * Provide extended autocompletions for dbt sources * Refactoring * Sort macros completions * Show dbt autocompletions for incomplete jinjas * Provide sources names as autocompletions * Provide sources names as autocompletions * Add e2e tests for sources autocompletions * Add e2e tests for macros autocompletions * Fix autocompletion feature for SQL * Fix autocompletion feature for SQL * Fix e2e test * Calculate dbt nodes maps when manifest changes * Fix dbt autocompletions * Describe dbt autocompletion feature in README * Add Completion for dbt feature into features table * Add unit tests for dbt completion providers * Fix README * Remove unused const * Rename CompletionProvider to SqlCompletionProvider * Refactoring * Refactoring * Clear manifest nodes maps before grouping * Refactoring * Refactoring * Refactoring * Refactoring * Refactoring * Remove unused consts * Refactoring * Refactoring * Refactoring * Refactoring * Refactoring * Create const with macros completions array * Refactoring * Refactoring * Refactoring * Refactoring * Add unit tests for cases when completion providers should return undefined * Improve StringBuilder * Use vscode type instead of custom one * Simplify completions provisioning * Simplify completions provisioning * Refactoring * Refactoring
- Loading branch information
1 parent
4036dcb
commit 7e858ea
Showing
44 changed files
with
1,117 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
select u.id, {{ extract_first_name('u.full_name') }} as first_name, {{ extract_last_name('u.full_name') }} as last_name, count(*) | ||
select u.id, {{ extract_first_name('u.full_name') }} as first_name, {{ dbt_postgres_test.extract_last_name('u.full_name') }} as last_name, count(*) | ||
from {{ ref('dbt_postgres_test', 'active_users') }} u | ||
join orders o on u.id = o.user_id | ||
group by u.id, u.full_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { assertThat, defined } from 'hamjest'; | ||
import { CompletionItem, CompletionItemKind, Position } from 'vscode'; | ||
import { assertCompletions } from '../asserts'; | ||
import { activateAndWait, getCustomDocUri, triggerCompletion } from '../helper'; | ||
|
||
suite('Should suggest macros completions', () => { | ||
const PROJECT_FILE_NAME = 'postgres/models/active_users_orders_count.sql'; | ||
|
||
const MACROS_COMPLETIONS = [ | ||
['extract_first_name', 'extract_first_name'], | ||
['extract_last_name', 'extract_last_name'], | ||
]; | ||
|
||
test('Should suggest macros', async () => { | ||
// arrange | ||
const docUri = getCustomDocUri(PROJECT_FILE_NAME); | ||
await activateAndWait(docUri); | ||
|
||
// act | ||
const actualCompletionList = await triggerCompletion(docUri, new Position(0, 15), 'e'); | ||
|
||
// assert | ||
const expectedCompletions = getMacrosCompletionList(); | ||
expectedCompletions.forEach(c => { | ||
const actualCompletion = actualCompletionList.items.find(a => a.label === c.label && a.insertText === c.insertText); | ||
assertThat(actualCompletion, defined()); | ||
}); | ||
}); | ||
|
||
test('Should suggest macros from package', async () => { | ||
const docUri = getCustomDocUri(PROJECT_FILE_NAME); | ||
await activateAndWait(docUri); | ||
await assertCompletions(docUri, new Position(0, 89), getMacrosCompletionList()); | ||
}); | ||
|
||
function getMacrosCompletionList(): CompletionItem[] { | ||
return MACROS_COMPLETIONS.map<CompletionItem>(c => ({ label: c[0], insertText: c[1], kind: CompletionItemKind.Value })); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { CompletionItem, CompletionItemKind, Position } from 'vscode'; | ||
import { assertCompletions } from '../asserts'; | ||
import { activateAndWait, getCustomDocUri, getTextInQuotesIfNeeded } from '../helper'; | ||
|
||
suite('Should suggest sources completions', () => { | ||
const PROJECT_FILE_NAME = 'postgres/models/active_users.sql'; | ||
|
||
const SOURCES_COMPLETIONS: [string, string][] = [['(dbt_postgres_test) users_orders', 'users_orders']]; | ||
const TABLES_COMPLETIONS: [string, string][] = [ | ||
['orders', 'orders'], | ||
['users', 'users'], | ||
]; | ||
|
||
test('Should suggest sources', async () => { | ||
const docUri = getCustomDocUri(PROJECT_FILE_NAME); | ||
await activateAndWait(docUri); | ||
await assertCompletions(docUri, new Position(1, 16), getSourcesCompletionList(SOURCES_COMPLETIONS, false)); | ||
}); | ||
|
||
test('Should suggest source tables', async () => { | ||
const docUri = getCustomDocUri(PROJECT_FILE_NAME); | ||
await activateAndWait(docUri); | ||
await assertCompletions(docUri, new Position(1, 32), getSourcesCompletionList(TABLES_COMPLETIONS, false)); | ||
}); | ||
|
||
function getSourcesCompletionList(completions: [string, string][], withQuotes: boolean): CompletionItem[] { | ||
return completions.map<CompletionItem>(c => ({ | ||
label: c[0], | ||
insertText: getTextInQuotesIfNeeded(c[1], withQuotes), | ||
kind: CompletionItemKind.Value, | ||
})); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import * as vscode from 'vscode'; | ||
import { activateAndWait, getDocUri, testCompletion } from './helper'; | ||
import { assertCompletions } from './asserts'; | ||
import { activateAndWait, getDocUri } from './helper'; | ||
|
||
suite('Should do completion with jinjas in query', () => { | ||
test('Should suggest table columns', async () => { | ||
const docUri = getDocUri('simple_select_dbt.sql'); | ||
await activateAndWait(docUri); | ||
|
||
await testCompletion(docUri, new vscode.Position(0, 8), { | ||
items: [ | ||
{ label: 'date', kind: vscode.CompletionItemKind.Value }, | ||
{ label: 'id', kind: vscode.CompletionItemKind.Value }, | ||
{ label: 'name', kind: vscode.CompletionItemKind.Value }, | ||
{ label: 'time', kind: vscode.CompletionItemKind.Value }, | ||
], | ||
}); | ||
await assertCompletions(docUri, new vscode.Position(0, 8), [ | ||
{ label: 'date', kind: vscode.CompletionItemKind.Value }, | ||
{ label: 'id', kind: vscode.CompletionItemKind.Value }, | ||
{ label: 'name', kind: vscode.CompletionItemKind.Value }, | ||
{ label: 'time', kind: vscode.CompletionItemKind.Value }, | ||
]); | ||
}); | ||
}); |
Oops, something went wrong.