diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java index 3db367a4af46..973b01810dd5 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java @@ -532,33 +532,34 @@ public Iterator streamTableColumns(ConnectorSession sessio .map(ignored -> singletonList(prefix.toSchemaTableName())) .orElseGet(() -> listTables(session, prefix.getSchema())); - return tables.stream().flatMap(table -> { - try { - if (redirectTable(session, table).isPresent()) { - // put "redirect marker" for current table - return Stream.of(TableColumnsMetadata.forRedirectedTable(table)); - } + return tables.stream() + .flatMap(table -> { + try { + if (redirectTable(session, table).isPresent()) { + // put "redirect marker" for current table + return Stream.of(TableColumnsMetadata.forRedirectedTable(table)); + } - // intentionally skip case when table snapshot is present but it lacks metadata portion - return metastore.getMetadata(metastore.getSnapshot(table, session), session).stream().map(metadata -> { - Map columnComments = getColumnComments(metadata); - Map columnsNullability = getColumnsNullability(metadata); - List columnMetadata = getColumns(metadata).stream() - .map(column -> getColumnMetadata(column, columnComments.get(column.getName()), columnsNullability.getOrDefault(column.getName(), true))) - .collect(toImmutableList()); - return TableColumnsMetadata.forTable(table, columnMetadata); - }); - } - catch (NotADeltaLakeTableException e) { - return Stream.empty(); - } - catch (RuntimeException e) { - // this may happen when table is being deleted concurrently, it still exists in metastore but TL is no longer present - // there can be several different exceptions thrown this is why all RTE are caught and ignored here - LOG.debug(e, "Ignored exception when trying to list columns from %s", table); - return Stream.empty(); - } - }) + // intentionally skip case when table snapshot is present but it lacks metadata portion + return metastore.getMetadata(metastore.getSnapshot(table, session), session).stream().map(metadata -> { + Map columnComments = getColumnComments(metadata); + Map columnsNullability = getColumnsNullability(metadata); + List columnMetadata = getColumns(metadata).stream() + .map(column -> getColumnMetadata(column, columnComments.get(column.getName()), columnsNullability.getOrDefault(column.getName(), true))) + .collect(toImmutableList()); + return TableColumnsMetadata.forTable(table, columnMetadata); + }); + } + catch (NotADeltaLakeTableException e) { + return Stream.empty(); + } + catch (RuntimeException e) { + // this may happen when table is being deleted concurrently, it still exists in metastore but TL is no longer present + // there can be several different exceptions thrown this is why all RTE are caught and ignored here + LOG.debug(e, "Ignored exception when trying to list columns from %s", table); + return Stream.empty(); + } + }) .iterator(); }