MCPcopy Index your code
hub / github.com/microsoft/SandDance / onQueryEvent

Function onQueryEvent

extensions/azdata-sanddance/src/extension.ts:37–75  ·  view source on GitHub ↗
(type: azdata.queryeditor.QueryEvent, document: azdata.queryeditor.QueryDocument, args: any)

Source from the content-addressed store, hash-verified

35 // Issue #6374 created in ADS repository to track this ask
36 azdata.queryeditor.registerQueryEventListener({
37 async onQueryEvent(type: azdata.queryeditor.QueryEvent, document: azdata.queryeditor.QueryDocument, args: any) {
38 if (type === 'visualize') {
39 const providerid = document.providerId;
40 const provider: azdata.QueryProvider = azdata.dataprotocol.getProvider(providerid, azdata.DataProviderType.QueryProvider);
41 const data = await provider.getQueryRows({
42 ownerUri: document.uri,
43 batchIndex: args.batchId,
44 resultSetIndex: args.id,
45 rowsStartIndex: 0,
46 rowsCount: args.rowCount,
47 });
48
49 const rows = data.resultSubset.rows;
50 const columns = args.columnInfo;
51 const rowsCount = args.rowCount;
52
53 // Create Json
54 const jsonArray: jsonType[] = [];
55
56 interface jsonType {
57 [key: string]: any
58 }
59
60 for (let row = 0; row < rowsCount; row++) {
61 const jsonObject: jsonType = {};
62 for (let col = 0; col < columns.length; col++) {
63 if (!rows[row][col].isNull) {
64 jsonObject[columns[col].columnName] = rows[row][col].displayValue;
65 }
66 // If display value is null, don't do anything for now
67 }
68 jsonArray.push(jsonObject);
69 }
70
71 viewInSandDance(() => {
72 return new Promise<string>(resolve => resolve(JSON.stringify(jsonArray)));
73 }, document.uri, 'json', context);
74 }
75 },
76 });
77}
78

Callers

nothing calls this directly

Calls 3

viewInSandDanceFunction · 0.85
getQueryRowsMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected