Querying table comments and parameters

Query the table parameters property inside the system database to extract catalog descriptions.

When you need to find the specific comment or configuration parameters of a table, you can retrieve this metadata from the TABLE_PARAMS table inside the sys database instead of accessing the backend database directly.

Ensure that you have access permissions to run the beeline client.

  1. Open your terminal interface and run the beeline client.
  2. Select the system database by running the following command:
    USE sys;
  3. Extract the table comments by running the following metadata query:
    SELECT  
      d.name AS db_name,  
      t.tbl_name AS tbl_name,  
      max(CASE WHEN p.param_key = 'comment' THEN p.param_value END) AS table_comment  
    FROM DBS d  
    JOIN TBLS t  
      ON d.db_id = t.db_id  
    LEFT JOIN TABLE_PARAMS p  
      ON p.tbl_id = t.tbl_id  
    WHERE t.tbl_type <> 'VIRTUAL_VIEW'  
      AND lower(d.name) NOT IN ('sys', 'information_schema')  
    GROUP BY d.name, t.tbl_name  
    ORDER BY db_name, tbl_name;