Certain psql macros generate queries that rely on pg_catalog existing; see for example #2156
Also, various Postgres-compatible tools such as BI software (e.g. #2206) and ORMs require either us supporting pg_catalog or writing an adapter that removes the need for that.
@justinj I'd be curious as to your opinion on how much work this is.
IME there's a very long tail of random features supported here. Personally I think the right move is to introduce some carefully-thought-out infrastructure for adding new system tables (unsure if Materialize already supports these) that can easily be added to as tools complain, since doing _everything_ is going to be a ton of work for very little incremental benefit.
To elaborate on Justin's excellent comment, the way to go about pg_catalog support is to start with a couple _end points_ that we know require pg_catalog, and aim to get support for those libraries.
Priority in picking library should start with enumerating:
I think Metabase is a great first start here - users want it, lots of the work perhaps overlaps with other JDBC-based tools? I think getdbt.com is a good one, but is gated on CTEs - but it has excellent tests. Postgrest would be useful as well as a third one. cc @awang to ultimately decide on the end points here.
\l, \d, and the other macros that @umanwizard mentioned are obvious ones as well.
Game plan:
Mirror show data as views (#913).
SHOW command, possibly SHOW DATABASES.mz_catalog.mz_databases as a built-in table.sql planner to rewrite SHOW DATABASES to SELECT * FROM mz_databases.SHOW commands.Start adding some tests of the JDBC metadata API to the Java smoke test. Add builtin pg_catalog views that are transformations over mz_catalog tables. A good place to start is probably getSchemas.
Implement enough of pg_catalog for Metabase (#3727) by repeating 2.
At some point:
pg_catalog tables rely on arrays (not lists).\l work (https://github.com/MaterializeInc/materialize/issues/2156#issuecomment-696918120)Do we have an open issue for making \d <table_name> work? For example, this works in Postgres:
postgres=# create table foo (one INT, two INT);
postgres=# \d
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | foo | table | postgres
(1 row)
postgres=# \dt
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | foo | table | postgres
(1 row)
postgres=# \d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
one | integer | | |
two | integer | | |
However, in Materialize, I get (where customer is a materialized view):
materialize=> \d customer
ERROR: Expected end of statement, found identifier
LINE 6: WHERE c.relname OPERATOR(pg_catalog.~) '^(customer)$'
Most helpful comment
IME there's a very long tail of random features supported here. Personally I think the right move is to introduce some carefully-thought-out infrastructure for adding new system tables (unsure if Materialize already supports these) that can easily be added to as tools complain, since doing _everything_ is going to be a ton of work for very little incremental benefit.