Code review comment: If `databases` is a `Stream<String>` you wouldn't need to collect the filtering results.  ``` Stream<String> databases =                 ctx.getCatalogManager().getCatalogOrThrowException(cName).listDatabases().stream();          if (likeType != null) {             databases =                     databases                             .filter(                                     row -> {                                         if (likeType == LikeType.ILIKE) {                                             return notLike                                                     != SqlLikeUtils.ilike(row, likePattern, "\\");                                         } else if (likeType == LikeType.LIKE) {                                             return notLike                                                     != SqlLikeUtils.like(row, likePattern, "\\");                                         }                                         return false;                                     });         } ```

Code under review:
public TableResultInternal execute(Context ctx) {
        String cName =
                catalogName == null ? ctx.getCatalogManager().getCurrentCatalog() : catalogName;
        List<String> databases =
                ctx.getCatalogManager().getCatalogOrThrowException(cName).listDatabases();

        if (likeType != null) {
            databases =
                    databases.stream()
                            .filter(
                                    row -> {
                                        if (likeType == LikeType.ILIKE) {
                                            return notLike
                                                    != SqlLikeUtils.ilike(row, likePattern, "\\");
                                        } else if (likeType == LikeType.LIKE) {
                                            return notLike
                                                    != SqlLikeUtils.like(row, likePattern, "\\");
                                        }
                                        return false;
                                    })
                            .collect(Collectors.toList());
        }

        return buildStringArrayResult(
                "database name", databases.stream().sorted().toArray(String[]::new));
    }

Line commented on: "database name", databases.stream().sorted().toArray(String[]::new));

Revised code:
public TableResultInternal execute(Context ctx) {
        String cName =
                catalogName == null ? ctx.getCatalogManager().getCurrentCatalog() : catalogName;
        Stream<String> databases =
                ctx.getCatalogManager().getCatalogOrThrowException(cName).listDatabases().stream();

        if (likeType != null) {
            databases =
                    databases.filter(
                            row -> {
                                if (likeType == LikeType.ILIKE) {
                                    return notLike != SqlLikeUtils.ilike(row, likePattern, "\\");
                                } else if (likeType == LikeType.LIKE) {
                                    return notLike != SqlLikeUtils.like(row, likePattern, "\\");
                                }
                                return false;
                            });
        }

        return buildStringArrayResult("database name", databases.sorted().toArray(String[]::new));
    }