Files
doris/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLE CREATION.md
qiye 3b8d48f08b [feature-wip](iceberg) Step1: Support create Iceberg external table (#7391)
Close related #7389

Support create Iceberg external table in Doris. 

This is the first step to support Iceberg external table.

### Create Iceberg external table
This pr describes two ways to create Iceberg external tables. Both ways do not require explicitly specifying column definitions, Doris automatically converts them based on Iceberg's column definitions.

1. Create an Iceberg external table directly

```sql
    CREATE [EXTERNAL] TABLE table_name 
    ENGINE = ICEBERG
    [COMMENT "comment"]
    PROPERTIES (
    "iceberg.database" = "iceberg_db_name",
    "iceberg.table" = "icberg_table_name",
    "iceberg.hive.metastore.uris"  =  "thrift://192.168.0.1:9083",
    "iceberg.catalog.type"  =  "HIVE_CATALOG"
    );
```

2. Create an Iceberg database and automatically create all the tables under that db.

```sql
    CREATE DATABASE db_name 
    [COMMENT "comment"]
    PROPERTIES (
    "iceberg.database" = "iceberg_db_name",
    "iceberg.hive.metastore.uris" = "thrift://192.168.0.1:9083",
    "iceberg.catalog.type" = "HIVE_CATALOG"
    );
```

### Show table creation

1. For individual tables you can view them with `help show create table`.

```sql 
mysql> show create table iceberg_db.logs_1;
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                                                                                                                                                                                                                                                                                 |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| logs_1 | CREATE TABLE `logs_1` (
  `level` varchar(-1) NOT NULL COMMENT "null",
  `event_time` datetime NOT NULL COMMENT "null",
  `message` varchar(-1) NOT NULL COMMENT "null"
) ENGINE=ICEBERG
COMMENT "ICEBERG"
PROPERTIES (
"iceberg.database" = "doris",
"iceberg.table" = "logs_1",
"iceberg.hive.metastore.uris"  =  "thrift://10.10.10.10:9087",
"iceberg.catalog.type"  =  "HIVE_CATALOG"
) |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```

2. For Iceberg database, you can view it with `help show table creation`.

```sql
mysql> show table creation from iceberg_db;
+--------+---------+---------------------+---------------------------------------------------------+
| Table  | Status  | Create Time         | Error Msg                                               |
+--------+---------+---------------------+---------------------------------------------------------+
| logs   | fail    | 2021-12-14 13:50:10 | Cannot convert unknown type to Doris type: list<string> |
| logs_1 | success | 2021-12-14 13:50:10 |                                                         |
+--------+---------+---------------------+---------------------------------------------------------+
2 rows in set (0.00 sec)
```

  This is a new syntax.
  
  Show table creation records in Iceberg database:
  
  Syntax:
  ```sql
      SHOW TABLE CREATION [FROM db] [LIKE mask]
  ```
2022-01-27 10:22:47 +08:00

4.2 KiB

title, language
title language
SHOW TABLE CREATION zh-CN

SHOW TABLE CREATION

Description

该语句用于展示指定的 Iceberg Database 建表任务的执行情况
语法:
    SHOW TABLE CREATION [FROM db_name] [LIKE table_name_wild];
    
说明:
    1. 使用说明
        1) 如果不指定 db_name,使用当前默认 db
        2) 如果使用 LIKE,则会匹配表名中包含 table_name_wild 的建表任务
    2. 各列含义说明
        1) Database: 数据库名称
        2) Table:要创建表的名称
        3) Status:表的创建状态,`success`/`fail`
        4) CreateTime:执行创建该表任务的时间
        5) Error Msg:创建表失败的错误信息,如果成功,则为空。

example

1. 展示默认 Iceberg db 中所有的建表任务
    SHOW TABLE CREATION;

    mysql> show table creation ;
    +----------------------------+--------+---------+---------------------+----------------------------------------------------------+
    | Database                   | Table  | Status  | Create Time         | Error Msg                                                |
    +----------------------------+--------+---------+---------------------+----------------------------------------------------------+
    | default_cluster:iceberg_db | logs_1 | success | 2022-01-24 19:42:45 |                                                          |
    | default_cluster:iceberg_db | logs   | fail    | 2022-01-24 19:42:45 | Cannot convert Iceberg type[list<string>] to Doris type. |
    +----------------------------+--------+---------+---------------------+----------------------------------------------------------+

2. 展示指定 Iceberg db 中的建表任务
    SHOW TABLE CREATION FROM example_db;

    mysql> show table creation from iceberg_db;
    +----------------------------+--------+---------+---------------------+----------------------------------------------------------+
    | Database                   | Table  | Status  | Create Time         | Error Msg                                                |
    +----------------------------+--------+---------+---------------------+----------------------------------------------------------+
    | default_cluster:iceberg_db | logs_1 | success | 2022-01-24 19:42:45 |                                                          |
    | default_cluster:iceberg_db | logs   | fail    | 2022-01-24 19:42:45 | Cannot convert Iceberg type[list<string>] to Doris type. |
    +----------------------------+--------+---------+---------------------+----------------------------------------------------------+
    
3. 展示指定 Iceberg db 中的建表任务,表名中包含字符串 "log" 的任务
    SHOW TABLE CREATION FROM example_db LIKE '%log%';

    mysql> show table creation from iceberg_db like "%1";
    +----------------------------+--------+---------+---------------------+-----------+
    | Database                   | Table  | Status  | Create Time         | Error Msg |
    +----------------------------+--------+---------+---------------------+-----------+
    | default_cluster:iceberg_db | logs_1 | success | 2022-01-24 19:42:45 |           |
    +----------------------------+--------+---------+---------------------+-----------+

keyword

SHOW,TABLE CREATION