ByteHouse Cloud Data Warehouse Edition supports federated queries using external tables. Users do not need to import data; they can directly query data in Paimon through Paimon external tables, providing flexibility and convenience in data processing. This article will introduce how to use Paimon external tables in ByteHouse.
For Paimon data tables, ByteHouse currently supports three methods for data mapping between ByteHouse and Paimon: Create Paimon external table, Create Paimon database, and Create Paimon external catalog.
Data mapping method | Data mapping description |
|---|---|
Create Paimon external table | Establish mapping from ByteHouse table to Paimon table at the table dimension. Schema changes in the source table are not directly synchronized; if changes occur, the external table in ByteHouse must be deleted and a new external table created. |
Create Paimon external database | Establish mapping from ByteHouse Database to Paimon Database at the database dimension. After establishing the database mapping, manual creation of table mappings is not required. Table mappings under the database can be automatically synchronized, and additions or deletions of Paimon tables can be detected. Schema changes in the source table can be directly synchronized to ByteHouse. |
Create Paimon external catalog | Establish mapping from ByteHouse Catalog to Paimon Catalog at the catalog (data directory) dimension. After establishing the catalog mapping, manual creation of database or table mappings is not required. Database and table mappings under the catalog can be automatically synchronized, and additions or deletions of Paimon databases or tables can be detected. Schema changes in the source table can be directly synchronized to ByteHouse. For details on creating a Paimon external catalog, see Paimon Catalog. |
The external table feature is designed to provide the capability to process data other than ByteHouse internal tables. With a simple DDL statement, you can create an external table in ByteHouse to establish an association between a ByteHouse table and an external data source.
Sub-items | Restriction description |
|---|---|
Alter operation | Currently, Alter operations cannot be performed on ByteHouse external tables or ByteHouse external databases. For example, external tables do not support adding columns, deleting columns, or renaming columns; external databases do not support |
Time Travel | The current implementation hides version information in the table name, that is,
In ByteHouse,
|
Automatic schema change detection |
|
Complex data types | Currently, complex data types are not supported as Nullable. |
By creating a ByteHouse external table, you establish a table-level mapping from the ByteHouse table to the Paimon table. Paimon's data can be stored on different distributed storage systems, such as HDFS or S3. The following will introduce the table creation statements for different distributed storage systems:
When creating an external table, you need to specify the associated external table database and table details. Currently, you can specify the column details of the external table, or omit column details and obtain the corresponding columns through automatic inference.
enable_schema_covert_fault_tolerance parameter controls how to handle cases where the automatically inferred type does not exist. When a type in Paimon cannot find a compatible type in ByteHouse: a value of 1 means to ignore; 0 means to report an error; the default value is 1.CREATE TABLE `{tableName}` ( `col_boolean` BOOLEAN, `col_tinyint` Int8, `col_smallint` Int16, `col_int` Int32, `col_bigint` Int64, `col_float` Float32, `col_double` Float64, `col_decimal` DECIMAL(10, 2), `col_date` DATE32, `col_time` DateTime, `col_timestamp` DateTime64(6), `col_char` FixedString(10), `col_varchar` String, `col_binary` FixedString(50), `col_varbinary` String, `col_array_int` Array(Int32), `col_map` Map(String, Int32), `col_struct` Tuple(`field_smallint` Int16, `field_varchar` String, `field_time` DateTime, `field_decimal` DECIMAL(28, 6), `field_varbinary` String) ) ENGINE = CnchPaimon('filesystem', '{warehouse}', '{paimonDatabaseName}', '{paimonTableName}');
Parameter | Configuration description |
|---|---|
Table description | Paimon table column names and types. For column type mapping rules, see the Column type mapping section below. tip When specifying column names, types, partition keys, and other descriptions:
|
Engine parameters (Engine) |
|
CREATE TABLE `{tableName}` ENGINE = CnchPaimon('filesystem', '{warehouse}', '{paimonDatabaseName}', '{paimonTableName}') SETTINGS enable_schema_covert_fault_tolerance = 0;
Parameter | Configuration description |
|---|---|
Table description | tableName: Name of the external table. Paimon table column names and types, as well as Partition By key, will be automatically inferred and created during table creation. For column type mapping rules, see the Column type mapping section below. |
Engine parameters (Engine) |
|
Settings (SETTINGS) | enable_schema_covert_fault_tolerance: Controls how to handle cases where automatic type inference fails. |
CREATE TABLE `{tableName}` ( `col_boolean` BOOLEAN, `col_tinyint` Int8, `col_smallint` Int16, `col_int` Int32, `col_bigint` Int64, `col_float` Float32, `col_double` Float64, `col_decimal` DECIMAL(10, 2), `col_date` DATE32, `col_time` DateTime, `col_timestamp` DateTime64(6), `col_char` FixedString(10), `col_varchar` String, `col_binary` FixedString(50), `col_varbinary` String, `col_array_int` Array(Int32), `col_map` Map(String, Int32), `col_struct` Tuple(`field_smallint` Int16, `field_varchar` String, `field_time` DateTime, `field_decimal` DECIMAL(28, 6), `field_varbinary` String) ) ENGINE = CnchPaimon('filesystem', '${warehouse}', '{paimonDatabaseName}', '{paimonTableName}') SETTINGS endpoint='{endpoint}', ak_id='{accessKey}', ak_secret='{accessSecretKey}', s3_extra_options='fs.s3a.connection.maximum=1000';
Parameter | Configuration description |
|---|---|
Table description | Paimon table column names and types. For column type mapping rules, see the Column type mapping section below. |
Engine parameters (Engine) |
|
Settings (SETTINGS) |
|
S3 parameter settings | s3_extra_options: Optional parameter for setting S3 tuning parameters. You can refer to the following format to set tuning parameters:
|
CREATE TABLE `{tableName}` ENGINE = CnchPaimon('filesystem', '${warehouse}', '{paimonDatabaseName}', '{paimonTableName}') SETTINGS endpoint='{endpoint}', ak_id='{accessKey}', ak_secret='{accessSecretKey}', s3_extra_options='fs.s3a.connection.maximum=1000', enable_schema_covert_fault_tolerance = 0;
Parameter | Configuration description |
|---|---|
Table creation description | Customize the Paimon external table name. The column names and types of the table, as well as the Partition By key, will be automatically inferred and created during table creation. For column type mapping rules, see the Column type mapping section below. |
Engine parameters (Engine) |
|
Settings (SETTINGS) |
|
S3 parameter settings | s3_extra_options: Optional parameter used to set S3 tuning parameters. You can refer to the following format to set tuning parameters:
|
By creating a ByteHouse external database, a mapping is established from ByteHouse Database to Paimon Database at the database level. After establishing the database mapping, it is no longer necessary to manually create table mappings; table mappings within the database can be automatically synchronized.
Paimon's data can be stored on different distributed storage systems, such as HDFS and S3. The following specifically introduces the table creation statements for different distributed storage systems:
CREATE DATABASE {databaseName} ENGINE = Paimon('filesystem', '{warehouse}', '{paimonDatabaseName}') SETTINGS enable_schema_covert_fault_tolerance = 1;
Parameter | Configuration description |
|---|---|
Database description | Customize the external database name. |
Engine parameters (Engine) |
|
Settings (SETTINGS) |
|
CREATE DATABASE {databaseName} ENGINE = Paimon('filesystem', '{warehouse}', '{paimonDatabaseName}') SETTINGS endpoint='{endpoint}', ak_id='{accessKey}', ak_secret='{accessSecretKey}', s3_extra_options='fs.s3a.connection.maximum=1000';
Parameter | Configuration description |
|---|---|
Database description | Customize the external database name. |
Engine parameters (Engine) |
|
Settings (SETTINGS) |
|
S3 Parameter setting | s3_extra_options: Optional parameter, used to set S3 tuning parameters. You can refer to the following format to set tuning parameters:
|
You can use INSERT INTO or INSERT OVERWRITE to write to an external table.
You can use a basic INSERT INTO statement to write data.
# 方式 1 INSERT INTO database.table VALUES (val1, val2, ...), (val1, val2, ...), ...; # 方式 2 INSERT INTO database.table SELECT [col1, col2, ... | *] FROM source_db.source_table;
Parameter | Configuration description |
|---|---|
Database and table description | database.table: Specify the name of the database and table to query. If you have already executed |
Description of write parameters |
|
This statement is used to overwrite the table.
# 方式 1 INSERT OVERWRITE database.table VALUES (val1, val2, ...), (val1, val2, ...), ...; # 方式 2 INSERT OVERWRITE database.table SELECT [col1, col2, ... | *] FROM source_db.source_table;
Parameter | Configuration description |
|---|---|
Database and table description | database.table: Specify the name of the database and table to query. If you have already executed |
Description of write parameters |
|
The query operation for external tables is the same as for regular tables.
SELECT * FROM t WHERE xxx;
The deletion operation for external database tables is the same as for regular tables.
Delete external database.
warning
After deleting an external database, all external tables under the external database will also be deleted at the same time. Please operate with caution.
DROP DATABASE example_db
Delete external data table.
DROP TABLE example_db.example_table
-- Specify snapshotId=123456789 SELECT * FROM tbl$version$123456789; -- Specify branch name=branch_1 SELECT * FROM tbl$version$branch_1; -- Specify tag name=tag_1 SELECT * FROM tbl$version$tag_1;
The following metadata tables are currently supported for Paimon tables:
SELECT * FROM tbl$metadata$manifests; SELECT * FROM tbl$metadata$snapshots; SELECT * FROM tbl$metadata$options; SELECT * FROM tbl$metadata$schemas; SELECT * FROM tbl$metadata$partitions; SELECT * FROM tbl$metadata$audit_log; SELECT * FROM tbl$metadata$files; SELECT * FROM tbl$metadata$tags; SELECT * FROM tbl$metadata$branches; SELECT * FROM tbl$metadata$consumers; SELECT * FROM tbl$metadata$ro; SELECT * FROM tbl$metadata$aggregation_fields; SELECT * FROM tbl$metadata$statistics;
tip
You can use the enable_schema_covert_fault_tolerance parameter to control how to handle unsupported data types when mapping data. When a type in Paimon cannot find a compatible type in ByteHouse: a value of 1 means ignore; 0 means report an error; the default value is 1.
Paimon type | ByteHouse type |
|---|---|
Boolean | UInt8 |
TinyInt | Int8 |
SmallInt | Int16 |
Int | Int32 |
BigInt | Int64 |
Float | Float32 |
Double | Float64 |
Date | Date32 |
Time | Not supported |
Timestamp Wihtout TZ | DateTime64(UTC) |
Timestamp With Local TZ | DateTime64(local time zone) |
Char | FixedString |
Varchar | String |
Binary | FixedString |
VarBinary | String |
Decimal | Deciaml |
Array | Array |
Map | Map |
Row | Tuple |