presto-main/src/main/java/io/prestosql/connector/system/TableCommentSystemTable.java/TableCommentSystemTable/cursor
class TableCommentSystemTable:    @Override
    public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
    {
        Optional<String> catalogFilter = stringFilter(constraint, 0);
        Optional<String> schemaFilter = stringFilter(constraint, 1);
        Optional<String> tableFilter = stringFilter(constraint, 2);

        Session session = ((FullConnectorSession) connectorSession).getSession();
        Builder table = InMemoryRecordSet.builder(COMMENT_TABLE);

        for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
            QualifiedTablePrefix prefix = tablePrefix(catalog, schemaFilter, tableFilter);

            Set<SchemaTableName> names = ImmutableSet.of();
            try {
                names = listTables(session, metadata, accessControl, prefix);
            }
            catch (PrestoException e) {
                // listTables throws an exception if cannot connect the database
                LOG.debug(e, "Failed to get tables for catalog: %s", catalog);
            }

            for (SchemaTableName name : names) {
                QualifiedObjectName tableName = new QualifiedObjectName(prefix.getCatalogName(), name.getSchemaName(), name.getTableName());
                Optional<String> comment = Optional.empty();
                try {
                    comment = metadata.getTableHandle(session, tableName)
                            .map(handle -> metadata.getTableMetadata(session, handle))
                            .map(metadata -> metadata.getMetadata().getComment())
                            .get();
                }
                catch (PrestoException e) {
                    // getTableHandle may throw an exception (e.g. Cassandra connector doesn't allow case insensitive column names)
                    LOG.debug(e, "Failed to get metadata for table: %s", name);
                }
                table.addRow(prefix.getCatalogName(), name.getSchemaName(), name.getTableName(), comment.orElse(null));
            }
        }

        return table.build().cursor();
    }