Skip to content

Commit 918f95b

Browse files
liuzulinsjc25-test
andauthored
feat(sagemakerunifiedstudio): Also show catalogs under Redshift nodes, improve error and empty state handling (aws#2202)
## Problem 1. To be consistent with SMUS data explorer, we should show catalogs under Redshift nodes as well 2. Need to address UX feedback on error handling and empty state ## Solution 1. Following the implementation in SMUS data explorer, also show catalogs under Redshift nodes 2. Addressed UX feedback: 1. icon size for table icon. 2. Error node and empty node --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Zulin Liu <[email protected]>
1 parent b40b9bd commit 918f95b

File tree

13 files changed

+538
-189
lines changed

13 files changed

+538
-189
lines changed

packages/core/package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,26 +449,33 @@
449449
"fontCharacter": "\\f1e4"
450450
}
451451
},
452-
"aws-schemas-registry": {
452+
"aws-sagemakerunifiedstudio-table": {
453453
"description": "AWS Contributed Icon",
454454
"default": {
455455
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
456456
"fontCharacter": "\\f1e5"
457457
}
458458
},
459-
"aws-schemas-schema": {
459+
"aws-schemas-registry": {
460460
"description": "AWS Contributed Icon",
461461
"default": {
462462
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
463463
"fontCharacter": "\\f1e6"
464464
}
465465
},
466-
"aws-stepfunctions-preview": {
466+
"aws-schemas-schema": {
467467
"description": "AWS Contributed Icon",
468468
"default": {
469469
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
470470
"fontCharacter": "\\f1e7"
471471
}
472+
},
473+
"aws-stepfunctions-preview": {
474+
"description": "AWS Contributed Icon",
475+
"default": {
476+
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
477+
"fontCharacter": "\\f1e8"
478+
}
472479
}
473480
}
474481
},
Lines changed: 3 additions & 0 deletions
Loading

packages/core/src/sagemakerunifiedstudio/explorer/nodes/lakehouseStrategy.ts

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,23 @@ import {
1414
NODE_ID_DELIMITER,
1515
NodeType,
1616
NodeData,
17-
DATA_DEFAULT_LAKEHOUSE_CONNECTION_NAME,
18-
DATA_DEFAULT_ATHENA_CONNECTION_NAME,
19-
DATA_DEFAULT_IAM_CONNECTION_NAME,
17+
DATA_DEFAULT_LAKEHOUSE_CONNECTION_NAME_REGEXP,
18+
DATA_DEFAULT_ATHENA_CONNECTION_NAME_REGEXP,
19+
DATA_DEFAULT_IAM_CONNECTION_NAME_REGEXP,
2020
AWS_DATA_CATALOG,
2121
DatabaseObjects,
22+
NO_DATA_FOUND_MESSAGE,
2223
} from './types'
23-
import { getLabel, isLeafNode, getIconForNodeType, getTooltip, createColumnTreeItem, getColumnType } from './utils'
24+
import {
25+
getLabel,
26+
isLeafNode,
27+
getIconForNodeType,
28+
getTooltip,
29+
createColumnTreeItem,
30+
getColumnType,
31+
createErrorItem,
32+
} from './utils'
33+
import { createPlaceholderItem } from '../../../shared/treeview/utils'
2434
import { Column, Database, Table } from '@aws-sdk/client-glue'
2535
import { ConnectionCredentialsProvider } from '../../auth/providers/connectionCredentialsProvider'
2636

@@ -68,7 +78,9 @@ export class LakehouseNode implements TreeNode {
6878
this.isLoading = false
6979
this.logger.error(`Failed to get children for node ${this.data.id}: ${(err as Error).message}`)
7080

71-
return [createErrorNode(`${this.id}${NODE_ID_DELIMITER}error`, err as Error, this)]
81+
const errorMessage = (err as Error).message
82+
void vscode.window.showErrorMessage(errorMessage)
83+
return [createErrorItem(errorMessage, 'getChildren', this.id) as LakehouseNode]
7284
}
7385
}
7486

@@ -142,9 +154,9 @@ export function createLakehouseConnectionNode(
142154

143155
// Check if this is a default connection
144156
const isDefaultConnection =
145-
connection.name.startsWith(DATA_DEFAULT_LAKEHOUSE_CONNECTION_NAME) ||
146-
connection.name.startsWith(DATA_DEFAULT_ATHENA_CONNECTION_NAME) ||
147-
connection.name.startsWith(DATA_DEFAULT_IAM_CONNECTION_NAME)
157+
DATA_DEFAULT_IAM_CONNECTION_NAME_REGEXP.test(connection.name) ||
158+
DATA_DEFAULT_LAKEHOUSE_CONNECTION_NAME_REGEXP.test(connection.name) ||
159+
DATA_DEFAULT_ATHENA_CONNECTION_NAME_REGEXP.test(connection.name)
148160

149161
// Follow the reference pattern with Promise.allSettled
150162
const [awsDataCatalogResult, catalogsResult] = await Promise.allSettled([
@@ -161,30 +173,24 @@ export function createLakehouseConnectionNode(
161173
const errors: LakehouseNode[] = []
162174

163175
if (awsDataCatalogResult.status === 'rejected') {
164-
errors.push(
165-
createErrorNode(
166-
`${node.id}${NODE_ID_DELIMITER}aws-catalog-error`,
167-
awsDataCatalogResult.reason as Error,
168-
node
169-
)
170-
)
176+
const errorMessage = (awsDataCatalogResult.reason as Error).message
177+
void vscode.window.showErrorMessage(errorMessage)
178+
errors.push(createErrorItem(errorMessage, 'aws-data-catalog', node.id) as LakehouseNode)
171179
}
172180

173181
if (catalogsResult.status === 'rejected') {
174-
errors.push(
175-
createErrorNode(
176-
`${node.id}${NODE_ID_DELIMITER}catalogs-error`,
177-
catalogsResult.reason as Error,
178-
node
179-
)
180-
)
182+
const errorMessage = (catalogsResult.reason as Error).message
183+
void vscode.window.showErrorMessage(errorMessage)
184+
errors.push(createErrorItem(errorMessage, 'catalogs', node.id) as LakehouseNode)
181185
}
182186

183187
const allNodes = [...awsDataCatalog, ...apiCatalogs, ...errors]
184-
return allNodes.length > 0 ? allNodes : [createEmptyNode(`${node.id}${NODE_ID_DELIMITER}empty`, node)]
188+
return allNodes.length > 0 ? allNodes : [createPlaceholderItem(NO_DATA_FOUND_MESSAGE) as LakehouseNode]
185189
} catch (err) {
186190
logger.error(`Failed to get Lakehouse catalogs: ${(err as Error).message}`)
187-
throw err
191+
const errorMessage = (err as Error).message
192+
void vscode.window.showErrorMessage(errorMessage)
193+
return [createErrorItem(errorMessage, 'lakehouse-catalogs', node.id) as LakehouseNode]
188194
}
189195
}
190196
)
@@ -391,7 +397,9 @@ function createCatalogNode(
391397
)
392398
} catch (err) {
393399
logger.error(`Failed to get databases for catalog ${catalogId}: ${(err as Error).message}`)
394-
throw err
400+
const errorMessage = (err as Error).message
401+
void vscode.window.showErrorMessage(errorMessage)
402+
return [createErrorItem(errorMessage, 'catalog-databases', node.id) as LakehouseNode]
395403
}
396404
}
397405
)
@@ -459,10 +467,12 @@ function createDatabaseNode(
459467

460468
return containerNodes.length > 0
461469
? containerNodes
462-
: [createEmptyNode(`${node.id}${NODE_ID_DELIMITER}empty`, node)]
470+
: [createPlaceholderItem(NO_DATA_FOUND_MESSAGE) as LakehouseNode]
463471
} catch (err) {
464472
logger.error(`Failed to get tables for database ${databaseName}: ${(err as Error).message}`)
465-
throw err
473+
const errorMessage = (err as Error).message
474+
void vscode.window.showErrorMessage(errorMessage)
475+
return [createErrorItem(errorMessage, 'database-tables', node.id) as LakehouseNode]
466476
}
467477
}
468478
)
@@ -559,27 +569,3 @@ function createContainerNode(
559569
}
560570
)
561571
}
562-
563-
/**
564-
* Creates an error node
565-
*/
566-
function createErrorNode(id: string, error: Error, parent?: LakehouseNode): LakehouseNode {
567-
return new LakehouseNode({
568-
id,
569-
nodeType: NodeType.ERROR,
570-
value: error,
571-
parent,
572-
})
573-
}
574-
575-
/**
576-
* Creates an empty node
577-
*/
578-
function createEmptyNode(id: string, parent?: LakehouseNode): LakehouseNode {
579-
return new LakehouseNode({
580-
id,
581-
nodeType: NodeType.EMPTY,
582-
value: 'No catalogs found',
583-
parent,
584-
})
585-
}

0 commit comments

Comments
 (0)