
# 系统表信息函数
#### format_type(type_oid, typemod)
描述：获取数据类型的SQL名称。
返回类型：text
备注：
format_type通过数据类型的类型OID以及可能的类型修饰词，返回其SQL名称。如果不知道具体的修饰词，则在类型修饰词的位置传入NULL。类型修饰词一般只对有长度限制的数据类型有意义。format_type所返回的SQL名称中包含数据类型的长度值，其大小是：实际存储长度len - sizeof(int32)，单位字节。数据存储时需要32位的空间来存储用户对数据类型的自定义长度信息，即实际存储长度要比用户定义长度多4个字节。在下例中，format_type返回的SQL名称为"character varying(6)"，6表示varchar类型的长度值是6字节，因此该类型的实际存储长度为10字节。
```
SELECT format_type((SELECT oid FROM pg_type WHERE typname='varchar'), 10);
     format_type      
----------------------
 character varying(6)
(1 row)
```
#### pg_get_schemas(schemaPattern)
描述：查询当前catalog中的schema, 参数schemaPattern可以是具体schema名字或者用%表示的通配符。如果schemaPattern为空（使用单引号替代参数），则返回所有的schema。
返回类型：text
```
select pg_get_schemas('');
     pg_get_schemas
----------------------
 test_orc
 test1_orc
 test_parquet
(3 row)
select pg_get_schemas('%orc');
     pg_get_schemas
----------------------
 test_orc
 test1_orc
(2 row)
select pg_get_schemas('test_orc');
     pg_get_schemas
----------------------
 test_orc
(1 row)
```
#### pg_get_tables(schemaPattern, tablePattern, tableTypes)
描述：查询当前catalog中满足条件的表信息，参数schemaPattern可以指定schema名字或用%表示的通配符；参数tablePattern可以指定表名字或用%表示的通配符；tableTypes可以指定表类型。具体表类型为MANAGED_TABLE、EXTERNAL_TABLE、VIRTUAL_VIEW、 MATERIALIZED_VIEW、 DICTIONARY_TABLE这几种类型。这三个参数如果为空（使用单引号替代参数），则返回所有的catalog、schema、表名、表类型、描述信息。
返回类型：返回如下字段组成的行集。
- catalog_name
- schema_name
- table_name
- table_type
- description
```
select pg_get_tables('','','');
     pg_get_tables
----------------------
 (catalog,schema_parquet,table1,MANAGED_TABLE,"")
 (catalog,schema_parquet,table2,MANAGED_TABLE,"")
 (catalog,schema_orc,table1,MANAGED_TABLE,"")
(3 row)
select pg_get_tables('%parquet','','MANAGED_TABLE');
     pg_get_tables
----------------------
 (catalog,schema_parquet,table1,MANAGED_TABLE,"")
 (catalog,schema_parquet,table2,MANAGED_TABLE,"")
(2 row)
```
#### pg_get_columns(schemaPattern, tableNamePattern, columnNamePattern)
描述：查询当前catalog中满足条件的列信息。参数schemaPattern可以指定schema名字或用%表示的通配符；参数tableNamePattern可以指定表名字或用%表示的通配符；参数columnNamePattern可以指定列名字或用%表示的通配符。
返回类型：返回如下字段组成的行集
- catalog_name
- schema_name
- table_name
- column_name
- origintype
- atttypid
- atttypmod
- typename
- typtype
- attnum
- description
- attnotnull
- description
```
select pg_get_columns('schema_parquet','customer','');
     pg_get_columns
----------------------
 (catalog,schema_parquet,customer,c_custkey,bigint,20,-1,int8,b,1,,f)
 (catalog,schema_parquet,customer,c_name,string,25,-1,text,b,2,,f)
 (catalog,schema_parquet,customer,c_address,string,25,-1,text,b,3,,f)
 (catalog,schema_parquet,customer,c_nationkey,bigint,20,-1,int8,b,4,,f)
 (catalog,schema_parquet,customer,c_phone,"char(15)",1042,19,bpchar,b,5,,f)
 (catalog,schema_parquet,customer,c_acctbal,"decimal(15,2)",1700,983046,numeric,b,6,,f)
 (catalog,schema_parquet,customer,c_mktsegment,"char(10)",1042,14,bpchar,b,7,,f)
 (catalog,schema_parquet,customer,c_comment,string,25,-1,text,b,8,,f)
(8 row)
```
#### pg_get_partition_keys(schema, table)
描述：查询当前catalog中指定schema名字、table名字的分区键信息。对于非分区表，则返回空集。
返回类型：返回如下字段组成的行集。
- table：表名字。
- partition_key：分区键信息。
```
select * from pg_get_partition_keys('test', 'iceberg_table');
     table     |  partition_key
---------------+-----------------
 iceberg_table | bucket(16,val)
 iceberg_table | truncate(10,id)
 iceberg_table | c3
 iceberg_table | year(ts)
(4 rows)
```
#### pg_get_partitions(table)
描述：查询当前catalog中当前schema下指定table名字的数据分区信息。
返回类型：返回如下字段组成的行集：
- partition_name：数据分区信息。
- location：数据分区对应的存储位置信息。
```
select * from pg_get_partitions('iceberg_table');
      partition_name      |                                                         location
--------------------------+---------------------------------------------------------------------------------------------------------------------------
 c3=1/data=hell/ts=2025   | obs://test/1b974a89-32b1-4b6b-8e14-548bba1b5007/test1/iceberg_test_part_expr/data/c3=1/data_trunc=hell/ts_year=2025/
 c3=20/data=he/ts=2024    | obs://test/1b974a89-32b1-4b6b-8e14-548bba1b5007/test1/iceberg_test_part_expr/data/c3=20/data_trunc=he/ts_year=2024/
 c3=100/data=zhan/ts=2025 | obs://test/1b974a89-32b1-4b6b-8e14-548bba1b5007/test1/iceberg_test_part_expr/data/c3=100/data_trunc=zhan/ts_year=2025/
 c3=6/data=hell/ts=2023   | obs://test/1b974a89-32b1-4b6b-8e14-548bba1b5007/test1/iceberg_test_part_expr/data/c3=6/data_trunc=hell/ts_year=2023/
 c3=60/data=hell/ts=2022  | obs://test/1b974a89-32b1-4b6b-8e14-548bba1b5007/test1/iceberg_test_part_expr/data/c3=60/data_trunc=hell/ts_year=2022/
(5 rows)
```
