apache / gravitino

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
https://gravitino.apache.org
Apache License 2.0
1.1k stars 345 forks source link

[Bug report] Postgresql schema `public` will be filted in `listDatabases` #2314

Closed zhoukangcn closed 9 months ago

zhoukangcn commented 9 months ago

Version

main branch

Describe what's wrong

In Catalog postgres, schema public will be filted in listDatabases

public static final Set<String> SYS_PG_DATABASE_NAMES =
      Collections.unmodifiableSet(
          new HashSet<String>() {
            {
              add("pg_toast");
              add("pg_catalog");
              add("public");
              add("information_schema");
            }
          });

but, user can create table in this schema. and we have many tables created in schema public in our production env.

Meanwhile, we can listTables using this schema

curl 'http://localhost:8090/api/metalakes/metalake/catalogs/pg_test/schemas/public/tables'

Error message and/or stacktrace

As shown above

How to reproduce

use PostgresSQL Catalog

Additional context

No response

justinmclean commented 9 months ago

Note in https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PUBLIC that by default tables without schema names are put here.

zhoukangcn commented 9 months ago

@justinmclean Yes, I think it's better not to treat pubic as the reserved database of system. Instead, users should be allowed to list this database.

jerryshao commented 9 months ago

@Clearvive would you please take a look at this issue?

FANNG1 commented 9 months ago

public schema is the default schema if not specifying schema names. I think we should remove public schema from SYS_PG_DATABASE_NAMES.

In the previous sections we created tables without specifying any schema names. By default such tables (and other objects) are automatically put into a schema named “public”. Every new database contains such a schema
FANNG1 commented 9 months ago

@zhoukangcn , would you like propose a PR to fix it?

lw-yang commented 9 months ago

@FANNG1 i will propose a PR to fix it