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] ```
70 lines
2.1 KiB
Markdown
70 lines
2.1 KiB
Markdown
---
|
|
{
|
|
"title": "CREATE DATABASE",
|
|
"language": "en"
|
|
}
|
|
---
|
|
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
or more contributor license agreements. See the NOTICE file
|
|
distributed with this work for additional information
|
|
regarding copyright ownership. The ASF licenses this file
|
|
to you under the Apache License, Version 2.0 (the
|
|
"License"); you may not use this file except in compliance
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, either express or implied. See the License for the
|
|
specific language governing permissions and limitations
|
|
under the License.
|
|
-->
|
|
|
|
# CREATE DATABASE
|
|
|
|
## Description
|
|
|
|
This statement is used to create a new database
|
|
Syntax:
|
|
CREATE DATABASE [IF NOT EXISTS] db_name
|
|
[PROPERTIES ("key"="value", ...)] ;
|
|
|
|
1. PROPERTIES
|
|
Additional information of a database, can be defaulted.
|
|
1) In case of iceberg, the following information needs to be provided in the properties.
|
|
```
|
|
PROPERTIES (
|
|
"iceberg.database" = "iceberg_db_name",
|
|
"iceberg.hive.metastore.uris" = "thrift://127.0.0.1:9083",
|
|
"iceberg.catalog.type" = "HIVE_CATALOG"
|
|
)
|
|
|
|
```
|
|
`iceberg.database` is the name of the database corresponding to Iceberg.
|
|
`iceberg.hive.metastore.uris` is the address of the hive metastore service.
|
|
`iceberg.catalog.type` defaults to `HIVE_CATALOG`. Currently, only `HIVE_CATALOG` is supported, more Iceberg catalog types will be supported later.
|
|
|
|
## example
|
|
1. Create a new database db_test
|
|
```
|
|
CREATE DATABASE db_test;
|
|
```
|
|
|
|
2. Create a new Iceberg database iceberg_test
|
|
```
|
|
CREATE DATABASE `iceberg_test`
|
|
PROPERTIES (
|
|
"iceberg.database" = "doris",
|
|
"iceberg.hive.metastore.uris" = "thrift://127.0.0.1:9083",
|
|
"iceberg.catalog.type" = "HIVE_CATALOG"
|
|
);
|
|
```
|
|
|
|
## keyword
|
|
CREATE,DATABASE
|
|
|