jerryshao commented on code in PR #6752:
URL: https://github.com/apache/gravitino/pull/6752#discussion_r2019471108
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/MetadataObjectService.java:
##########
@@ -389,6 +261,51 @@ public static Map<Long, String>
getTableObjectsFullName(List<Long> tableIds) {
return tableIdAndNameMap;
}
+ /**
+ * Retrieves a map of column object IDs to their full names.
+ *
+ * @param columnsIds A list of column object IDs to fetch names for.
+ * @return A Map where the key is the column ID and the value is the column
full name. The map may
+ * contain null values for the names if its parent object is deleted.
Returns an empty map if
+ * no column objects are found for the given IDs. {@code @example} value
of table full name:
+ * "catalog1.schema1.table1.column1"
+ */
+ public static Map<Long, String> getColumnObjectsFullName(List<Long>
columnsIds) {
+ List<ColumnPO> columnPOs =
+ SessionUtils.getWithoutCommit(
+ TableColumnMapper.class, mapper ->
mapper.listColumnPOsByTableIds(columnsIds));
+
+ if (columnPOs == null || columnPOs.isEmpty()) {
+ return new HashMap<>();
+ }
+
+ List<Long> tableIds =
columnPOs.stream().map(ColumnPO::getTableId).collect(Collectors.toList());
+ Map<Long, String> tableIdAndNameMap = getTableObjectsFullName(tableIds);
+
+ HashMap<Long, String> columnIdAndNameMap = new HashMap<>();
+
+ columnPOs.forEach(
+ columnPO -> {
+ // since the table can be deleted, we need to check the null value,
+ // and when the table is deleted, we will set fullName of column to
+ // null
+ String tableName =
tableIdAndNameMap.getOrDefault(columnPO.getTableId(), null);
+ if (tableName == null) {
+ LOG.warn(
+ "The table '{}' of column '{}' may be deleted",
+ columnPO.getTableId(),
+ columnPO.getColumnId());
+ columnIdAndNameMap.put(columnPO.getColumnId(), null);
+ return;
Review Comment:
What will be happened if table name is null? Shall we throw an exception
here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]