In order to cooperate with Doris's successful graduation from Apache, the Doris official website also needs a new look and more powerful feature, so we decided to redesign the Doris official website. The code and documents of the new official website are included in this PR. Since the new website is completely rewritten, the content and structure of the project are different from the previous one. In particular, the directory structure of documents has changed, and the number of documents is large, so the number of files in this PR is very large. In the old website,all English documents are in the en/ directory, and Chinese documents in the zh-CN/ directory, but in the new website,the documents are split into multiple directories according to the nav. The document's directory structure changes as follows: ``` docs (old website) | |—— .vuepress (library) | |—— en | | |—— admin-manual │ │ |—— advanced | | |—— article | | |—— benchmark | | |—— case-user | | |—— community | | |—— data-operate | | |—— data-table | | |—— design | | |—— developer-guide | | |—— downloads | | |—— ecosystem | | |—— faq | | |—— get-starting | | |—— install | | |—— sql-manual | | |—— summary | | |___ README.md | |—— zh-CN ... docs (new website) | |—— .vuepress (library) | |—— en | | |—— community (unchanged, community nav) │ │ |—— developer (new directory, developer nav) │ │ | |—— design (moved from en/design) │ │ | |__ developer-guide (moved from en/developer-guide) | | |—— docs (new directory, all children directories moved from en/, document nav) │ │ | |—— admin-manual │ │ | |—— advanced │ │ | |—— benchmark │ │ | |—— data-operate │ │ | |—— data-table │ │ | |—— ecosystem │ │ | |—— faq │ │ | |—— get-starting │ │ | |—— install │ │ | |—— sql-manual │ │ | |—— summary | | |—— downloads (unchanged, downloads nav) | | |—— userCase (moved from en/case-user, user nav) | | |___ README.md | |—— zh-CN ... ```
7.5 KiB
title, language
| title | language |
|---|---|
| CREATE-EXTERNAL-TABLE | en |
CREATE-EXTERNAL-TABLE
Name
CREATE EXTERNAL TABLE
Description
This statement is used to create an external table, see CREATE TABLE for the specific syntax.
Which type of external table is mainly identified by the ENGINE type, currently MYSQL, BROKER, HIVE, ICEBERG, HUDI are optional
-
If it is mysql, you need to provide the following information in properties:
PROPERTIES ( "host" = "mysql_server_host", "port" = "mysql_server_port", "user" = "your_user_name", "password" = "your_password", "database" = "database_name", "table" = "table_name" )and there is an optional propertiy "charset" which can set character fom mysql connection, default value is "utf8". You can set another value "utf8mb4" instead of "utf8" when you need.
Notice:
-
"table_name" in "table" entry is the real table name in mysql. The table_name in the CREATE TABLE statement is the name of the mysql table in Doris, which can be different.
-
The purpose of creating a mysql table in Doris is to access the mysql database through Doris. Doris itself does not maintain or store any mysql data.
-
-
If it is a broker, it means that the access to the table needs to pass through the specified broker, and the following information needs to be provided in properties:
PROPERTIES ( "broker_name" = "broker_name", "path" = "file_path1[,file_path2]", "column_separator" = "value_separator" "line_delimiter" = "value_delimiter" )In addition, you need to provide the Property information required by the Broker, and pass it through the BROKER PROPERTIES, for example, HDFS needs to pass in
BROKER PROPERTIES( "username" = "name", "password" = "password" )According to different Broker types, the content that needs to be passed in is also different.
Notice:
- If there are multiple files in "path", separate them with comma [,]. If the filename contains a comma, use %2c instead. If the filename contains %, use %25 instead
- Now the file content format supports CSV, and supports GZ, BZ2, LZ4, LZO (LZOP) compression formats.
-
If it is hive, you need to provide the following information in properties:
PROPERTIES ( "database" = "hive_db_name", "table" = "hive_table_name", "hive.metastore.uris" = "thrift://127.0.0.1:9083" )Where database is the name of the library corresponding to the hive table, table is the name of the hive table, and hive.metastore.uris is the address of the hive metastore service.
-
In case of iceberg, you need to provide the following information in properties:
PROPERTIES ( "iceberg.database" = "iceberg_db_name", "iceberg.table" = "iceberg_table_name", "iceberg.hive.metastore.uris" = "thrift://127.0.0.1:9083", "iceberg.catalog.type" = "HIVE_CATALOG" )Where database is the library name corresponding to Iceberg; table is the corresponding table name in Iceberg; hive.metastore.uris is the hive metastore service address; catalog.type defaults to HIVE_CATALOG. Currently only HIVE_CATALOG is supported, more Iceberg catalog types will be supported in the future.
-
In case of hudi, you need to provide the following information in properties:
PROPERTIES ( "hudi.database" = "hudi_db_in_hive_metastore", "hudi.table" = "hudi_table_in_hive_metastore", "hudi.hive.metastore.uris" = "thrift://127.0.0.1:9083" )Where hudi.database is the corresponding database name in HiveMetaStore; hudi.table is the corresponding table name in HiveMetaStore; hive.metastore.uris is the hive metastore service address;
Example
-
Create a MYSQL external table
Create mysql table directly from outer table information
CREATE EXTERNAL TABLE example_db.table_mysql ( k1 DATE, k2 INT, k3 SMALLINT, k4 VARCHAR(2048), k5 DATETIME ) ENGINE=mysql PROPERTIES ( "host" = "127.0.0.1", "port" = "8239", "user" = "mysql_user", "password" = "mysql_passwd", "database" = "mysql_db_test", "table" = "mysql_table_test", "charset" = "utf8mb4" )Create mysql table through External Catalog Resource
# Create Resource first CREATE EXTERNAL RESOURCE "mysql_resource" PROPERTIES ( "type" = "odbc_catalog", "user" = "mysql_user", "password" = "mysql_passwd", "host" = "127.0.0.1", "port" = "8239" ); # Then create mysql external table through Resource CREATE EXTERNAL TABLE example_db.table_mysql ( k1 DATE, k2 INT, k3 SMALLINT, k4 VARCHAR(2048), k5 DATETIME ) ENGINE=mysql PROPERTIES ( "odbc_catalog_resource" = "mysql_resource", "database" = "mysql_db_test", "table" = "mysql_table_test" ) -
Create a broker external table with data files stored on HDFS, the data is split with "|", and "\n" is newline
CREATE EXTERNAL TABLE example_db.table_broker ( k1 DATE, k2 INT, k3 SMALLINT, k4 VARCHAR(2048), k5 DATETIME ) ENGINE=broker PROPERTIES ( "broker_name" = "hdfs", "path" = "hdfs://hdfs_host:hdfs_port/data1,hdfs://hdfs_host:hdfs_port/data2,hdfs://hdfs_host:hdfs_port/data3%2c4", "column_separator" = "|", "line_delimiter" = "\n" ) BROKER PROPERTIES ( "username" = "hdfs_user", "password" = "hdfs_password" ) -
Create a hive external table
CREATE TABLE example_db.table_hive ( k1 TINYINT, k2 VARCHAR(50), v INT ) ENGINE=hive PROPERTIES ( "database" = "hive_db_name", "table" = "hive_table_name", "hive.metastore.uris" = "thrift://127.0.0.1:9083" ); -
Create an Iceberg skin
CREATE TABLE example_db.t_iceberg ENGINE=ICEBERG PROPERTIES ( "iceberg.database" = "iceberg_db", "iceberg.table" = "iceberg_table", "iceberg.hive.metastore.uris" = "thrift://127.0.0.1:9083", "iceberg.catalog.type" = "HIVE_CATALOG" ); -
Create an Hudi external table
create hudi table without schema(recommend)
CREATE TABLE example_db.t_hudi ENGINE=HUDI PROPERTIES ( "hudi.database" = "hudi_db_in_hive_metastore", "hudi.table" = "hudi_table_in_hive_metastore", "hudi.hive.metastore.uris" = "thrift://127.0.0.1:9083" );create hudi table with schema
CREATE TABLE example_db.t_hudi ( `id` int NOT NULL COMMENT "id number", `name` varchar(10) NOT NULL COMMENT "user name" ) ENGINE=HUDI PROPERTIES ( "hudi.database" = "hudi_db_in_hive_metastore", "hudi.table" = "hudi_table_in_hive_metastore", "hudi.hive.metastore.uris" = "thrift://127.0.0.1:9083" );
Keywords
CREATE, EXTERNAL, TABLE