Skip to content

Commit 603cb1a

Browse files
authored
Merge pull request #2 from deepnote/ss/improvements-2
2 parents d545519 + 2928b24 commit 603cb1a

13 files changed

+502
-84
lines changed

example/monaco_editor/.sqllsrc.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"adapter": "postgres",
3-
"host": "postgres",
4-
"port": 5432,
5-
"user": "sqlls",
6-
"password": "sqlls",
7-
"database": "postgres_db"
8-
}
2+
"name": "pyspark-conf",
3+
"adapter": "json",
4+
"filename": "testing.schema.json"
5+
}
Lines changed: 348 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,348 @@
1+
{
2+
"functions": [],
3+
"tables": [
4+
{
5+
"columns": [
6+
{
7+
"columnName": "id",
8+
"description": "integer",
9+
"metadata": {},
10+
"type": "integer"
11+
},
12+
{
13+
"columnName": "name",
14+
"description": "string",
15+
"metadata": {
16+
"description": "new description"
17+
},
18+
"type": "string"
19+
},
20+
{
21+
"columnName": "age",
22+
"description": "integer",
23+
"metadata": {},
24+
"type": "integer"
25+
},
26+
{
27+
"columnName": "books",
28+
"description": "array",
29+
"metadata": {},
30+
"type": "array"
31+
},
32+
{
33+
"columnName": "struct_col",
34+
"description": "struct",
35+
"metadata": {},
36+
"type": "struct"
37+
},
38+
{
39+
"columnName": "map_col",
40+
"description": "map",
41+
"metadata": {},
42+
"type": "map"
43+
}
44+
],
45+
"database": "school",
46+
"tableName": "student"
47+
},
48+
{
49+
"database": "school",
50+
"tableName": "nested_table",
51+
"columns": [
52+
{
53+
"columnName": "col1",
54+
"description": "the desc. text"
55+
},
56+
{
57+
"columnName": "struct_col",
58+
"description": "the desc. text"
59+
}
60+
]
61+
},
62+
{
63+
"database": "tales",
64+
"tableName": "tbl1",
65+
"columns": [
66+
{
67+
"columnName": "one",
68+
"description": "one(Type: varchar(10), Null: No, Default: null)"
69+
},
70+
{
71+
"columnName": "two",
72+
"description": "two(Type: smallint, Null: No, Default: null)"
73+
}
74+
]
75+
},
76+
{
77+
"database": "tales",
78+
"tableName": "contacts",
79+
"columns": [
80+
{
81+
"columnName": "contact_id",
82+
"description": "contact_id(Type: INTEGER, Null: No, Default: null)"
83+
},
84+
{
85+
"columnName": "first_name",
86+
"description": "first_name(Type: TEXT, Null: Yes, Default: null)"
87+
},
88+
{
89+
"columnName": "last_name",
90+
"description": "last_name(Type: TEXT, Null: Yes, Default: null)"
91+
},
92+
{
93+
"columnName": "email",
94+
"description": "email(Type: TEXT, Null: Yes, Default: null)"
95+
},
96+
{
97+
"columnName": "phone",
98+
"description": "phone(Type: TEXT, Null: Yes, Default: null)"
99+
}
100+
]
101+
},
102+
{
103+
"database": null,
104+
"tableName": "unqualified_table",
105+
"columns": [
106+
{
107+
"columnName": "group_id",
108+
"description": "group_id(Type: INTEGER, Null: No, Default: null)"
109+
},
110+
{
111+
"columnName": "name",
112+
"description": "name(Type: TEXT, Null: Yes, Default: null)"
113+
}
114+
]
115+
},
116+
{
117+
"database": "tales",
118+
"catalog": "db1",
119+
"tableName": "extra_qualified_table",
120+
"columns": [
121+
{
122+
"columnName": "contact_id",
123+
"description": "contact_id(Type: INTEGER, Null: No, Default: null)"
124+
},
125+
{
126+
"columnName": "group_id",
127+
"description": "group_id(Type: INTEGER, Null: No, Default: null)"
128+
}
129+
]
130+
},
131+
{
132+
"database": "tales",
133+
"tableName": "COMPANY",
134+
"columns": [
135+
{
136+
"columnName": "ID",
137+
"description": "ID(Type: INT, Null: Yes, Default: null)"
138+
},
139+
{
140+
"columnName": "NAME",
141+
"description": "NAME(Type: TEXT, Null: Yes, Default: null)"
142+
},
143+
{
144+
"columnName": "AGE",
145+
"description": "AGE(Type: INT, Null: Yes, Default: null)"
146+
},
147+
{
148+
"columnName": "ADDRESS",
149+
"description": "ADDRESS(Type: CHAR(50), Null: No, Default: null)"
150+
},
151+
{
152+
"columnName": "SALARY",
153+
"description": "SALARY(Type: REAL, Null: No, Default: null)"
154+
}
155+
]
156+
},
157+
{
158+
"database": "tales",
159+
"tableName": "employees",
160+
"columns": [
161+
{
162+
"columnName": "job_id",
163+
"description": ""
164+
},
165+
{
166+
"columnName": "employee_id",
167+
"description": ""
168+
},
169+
{
170+
"columnName": "manager_id",
171+
"description": ""
172+
},
173+
{
174+
"columnName": "department_id",
175+
"description": ""
176+
},
177+
{
178+
"columnName": "first_name",
179+
"description": ""
180+
},
181+
{
182+
"columnName": "last_name",
183+
"description": ""
184+
},
185+
{
186+
"columnName": "email",
187+
"description": ""
188+
},
189+
{
190+
"columnName": "phone_number",
191+
"description": ""
192+
},
193+
{
194+
"columnName": "hire_date",
195+
"description": ""
196+
},
197+
{
198+
"columnName": "salary",
199+
"description": ""
200+
},
201+
{
202+
"columnName": "commision_pct",
203+
"description": ""
204+
}
205+
]
206+
},
207+
{
208+
"database": "tales",
209+
"tableName": "jobs",
210+
"columns": [
211+
{
212+
"columnName": "job_id",
213+
"description": ""
214+
},
215+
{
216+
"columnName": "job_title",
217+
"description": ""
218+
},
219+
{
220+
"columnName": "min_salary",
221+
"description": ""
222+
},
223+
{
224+
"columnName": "max_salary",
225+
"description": ""
226+
},
227+
{
228+
"columnName": "created_at",
229+
"description": ""
230+
},
231+
{
232+
"columnName": "updated_at",
233+
"description": ""
234+
}
235+
]
236+
},
237+
{
238+
"database": "tales",
239+
"tableName": "job_history",
240+
"columns": [
241+
{
242+
"columnName": "employee_id",
243+
"description": ""
244+
},
245+
{
246+
"columnName": "start_date",
247+
"description": ""
248+
},
249+
{
250+
"columnName": "end_date",
251+
"description": ""
252+
},
253+
{
254+
"columnName": "job_id",
255+
"description": ""
256+
},
257+
{
258+
"columnName": "department_id",
259+
"description": ""
260+
}
261+
]
262+
},
263+
{
264+
"database": "tales",
265+
"tableName": "departments",
266+
"columns": [
267+
{
268+
"columnName": "department_id",
269+
"description": ""
270+
},
271+
{
272+
"columnName": "department_name",
273+
"description": ""
274+
},
275+
{
276+
"columnName": "manager_id",
277+
"description": ""
278+
},
279+
{
280+
"columnName": "location_id",
281+
"description": ""
282+
}
283+
]
284+
},
285+
{
286+
"database": "tales",
287+
"tableName": "locations",
288+
"columns": [
289+
{
290+
"columnName": "location_id",
291+
"description": ""
292+
},
293+
{
294+
"columnName": "street_address",
295+
"description": ""
296+
},
297+
{
298+
"columnName": "postal_code",
299+
"description": ""
300+
},
301+
{
302+
"columnName": "city",
303+
"description": ""
304+
},
305+
{
306+
"columnName": "state_province",
307+
"description": ""
308+
},
309+
{
310+
"columnName": "country_id",
311+
"description": ""
312+
}
313+
]
314+
},
315+
{
316+
"database": "tales",
317+
"tableName": "countries",
318+
"columns": [
319+
{
320+
"columnName": "country_id",
321+
"description": ""
322+
},
323+
{
324+
"columnName": "country_name",
325+
"description": ""
326+
},
327+
{
328+
"columnName": "region_id",
329+
"description": ""
330+
}
331+
]
332+
},
333+
{
334+
"database": "tales",
335+
"tableName": "regions",
336+
"columns": [
337+
{
338+
"columnName": "region_id",
339+
"description": ""
340+
},
341+
{
342+
"columnName": "region_name",
343+
"description": ""
344+
}
345+
]
346+
}
347+
]
348+
}

packages/server/src/complete/Identifier.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { CompletionItem, CompletionItemKind } from 'vscode-languageserver-types'
2-
import { makeTableAlias } from './StringUtils'
32

43
export const ICONS = {
54
KEYWORD: CompletionItemKind.Text,
@@ -46,14 +45,12 @@ export class Identifier {
4645
const idx = this.lastToken.lastIndexOf('.')
4746
const label = this.identifier.substring(idx + 1)
4847
let kindName: string
49-
let tableAlias = ''
5048
if (this.kind === ICONS.TABLE) {
5149
let tableName = label
5250
const i = tableName.lastIndexOf('.')
5351
if (i > 0) {
5452
tableName = label.substring(i + 1)
5553
}
56-
tableAlias = this.onClause === 'FROM' ? makeTableAlias(tableName) : ''
5754
kindName = 'table'
5855
} else {
5956
kindName = 'column'
@@ -66,11 +63,7 @@ export class Identifier {
6663
}
6764

6865
if (this.kind === ICONS.TABLE) {
69-
if (tableAlias) {
70-
item.insertText = `${label} AS ${tableAlias}`
71-
} else {
72-
item.insertText = label
73-
}
66+
item.insertText = label
7467
}
7568
return item
7669
}

0 commit comments

Comments
 (0)