diff --git a/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java b/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java index 2b5ad917851b..8f4f1b863edf 100644 --- a/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java +++ b/plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoMetadata.java @@ -129,7 +129,7 @@ public ConnectorTableMetadata getTableMetadata(ConnectorSession session, Connect { requireNonNull(tableHandle, "tableHandle is null"); SchemaTableName tableName = getTableName(tableHandle); - return getTableMetadata(session, tableName); + return getTableMetadata(tableName); } @Override @@ -166,7 +166,7 @@ public Map> listTableColumns(ConnectorSess ImmutableMap.Builder> columns = ImmutableMap.builder(); for (SchemaTableName tableName : listTables(session, prefix)) { try { - columns.put(tableName, getTableMetadata(session, tableName).getColumns()); + columns.put(tableName, getTableMetadata(tableName).getColumns()); } catch (NotFoundException e) { // table disappeared during listing operation @@ -465,16 +465,13 @@ private static SchemaTableName getTableName(ConnectorTableHandle tableHandle) return ((MongoTableHandle) tableHandle).getSchemaTableName(); } - private ConnectorTableMetadata getTableMetadata(ConnectorSession session, SchemaTableName tableName) + private ConnectorTableMetadata getTableMetadata(SchemaTableName tableName) { MongoTable mongoTable = mongoSession.getTable(tableName); - MongoTableHandle tableHandle = mongoTable.getTableHandle(); - List columns = - getColumnHandles(session, tableHandle).values().stream() - .map(MongoColumnHandle.class::cast) - .map(MongoColumnHandle::toColumnMetadata) - .collect(toImmutableList()); + List columns = mongoTable.getColumns().stream() + .map(MongoColumnHandle::toColumnMetadata) + .collect(toImmutableList()); return new ConnectorTableMetadata(tableName, columns, ImmutableMap.of(), mongoTable.getComment()); }