Skip to content

Commit bbc720d

Browse files
authored
docs: add Iceberg table write support documentation (databend#19200) (#3079)
Document the new INSERT INTO support for Iceberg tables, including CREATE TABLE with ENGINE=ICEBERG, PARTITION BY, supported data types, and examples for non-partitioned, single-field, and multi-field partitioned tables.
1 parent 9adb667 commit bbc720d

1 file changed

Lines changed: 124 additions & 1 deletion

File tree

  • docs/en/sql-reference/00-sql-reference/30-table-engines

docs/en/sql-reference/00-sql-reference/30-table-engines/02-iceberg.md

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ slug: /sql-reference/table-engines/iceberg
77

88
import FunctionDescription from '@site/src/components/FunctionDescription';
99

10-
<FunctionDescription description="Introduced or updated: v1.2.668"/>
10+
<FunctionDescription description="Introduced or updated: v1.2.725"/>
1111

1212
Databend supports the integration of an [Apache Iceberg™](https://iceberg.apache.org/) catalog, enhancing its compatibility and versatility for data management and analytics. This extends Databend's capabilities by seamlessly incorporating the powerful metadata and storage management capabilities of Apache Iceberg™ into the platform.
1313

@@ -416,6 +416,129 @@ iceberg_table_meta_count = 0
416416

417417
In addition to metadata caching, Databend also supports table data caching for Iceberg catalog tables, similar to Fuse tables. For more information on data caching, refer to the [cache section](/guides/self-hosted/references/node-config/query-config#cache-section) in the Query Configurations reference.
418418

419+
## Writing to Iceberg Tables
420+
421+
Databend supports writing data to Iceberg tables using `INSERT INTO`. You can create Iceberg tables directly with the `ENGINE = ICEBERG` clause and optionally define partition columns using `PARTITION BY`.
422+
423+
### Creating Iceberg Tables
424+
425+
#### Syntax
426+
427+
```sql
428+
CREATE TABLE <table_name> (
429+
<column_definitions>
430+
) ENGINE = ICEBERG
431+
[PARTITION BY (<column1>[, <column2>, ...])];
432+
```
433+
434+
- `ENGINE = ICEBERG`: Specifies that the table is stored in Iceberg format.
435+
- `PARTITION BY`: Optional. Defines one or more columns for partitioning the table data.
436+
437+
#### Supported Data Types
438+
439+
The following Databend data types are supported for writing to Iceberg tables:
440+
441+
| Databend Type | Iceberg Type |
442+
|---------------|-------------|
443+
| BOOLEAN | Boolean |
444+
| INT | Int |
445+
| BIGINT | Long |
446+
| FLOAT | Float |
447+
| DOUBLE | Double |
448+
| STRING | String |
449+
| DATE | Date |
450+
| TIMESTAMP | Timestamp |
451+
452+
### Inserting Data
453+
454+
Use standard `INSERT INTO` statements to write data into Iceberg tables:
455+
456+
```sql
457+
INSERT INTO <table_name> VALUES (...), (...);
458+
```
459+
460+
Both partitioned and non-partitioned tables support single-row and multi-row inserts. For partitioned tables, Databend automatically routes rows to the correct partitions. Null values in partition columns are also supported.
461+
462+
### Examples
463+
464+
#### Non-Partitioned Table
465+
466+
```sql
467+
CREATE TABLE t_scores(id INT, name STRING, score DOUBLE) ENGINE = ICEBERG;
468+
469+
INSERT INTO t_scores VALUES (1, 'alice', 85.5);
470+
INSERT INTO t_scores VALUES (2, 'bob', 90.0), (3, 'charlie', 75.5);
471+
472+
SELECT * FROM t_scores;
473+
474+
┌──────────────────────────────────────────┐
475+
│ id │ name │ score │
476+
├────────┼──────────┼─────────────────────┤
477+
1 │ alice │ 85.5
478+
2 │ bob │ 90.0
479+
3 │ charlie │ 75.5
480+
└──────────────────────────────────────────┘
481+
```
482+
483+
#### Single-Field Partitioned Table
484+
485+
```sql
486+
CREATE TABLE t_partitioned(id INT, category STRING, amount DOUBLE)
487+
ENGINE = ICEBERG
488+
PARTITION BY (category);
489+
490+
INSERT INTO t_partitioned VALUES (1, 'A', 100.5);
491+
INSERT INTO t_partitioned VALUES (2, 'B', 200.0), (3, 'A', 150.5), (4, 'C', 400.0);
492+
493+
SELECT * FROM t_partitioned;
494+
495+
┌──────────────────────────────────────────────┐
496+
│ id │ category │ amount │
497+
├────────┼────────────┼────────────────────────┤
498+
1 │ A │ 100.5
499+
3 │ A │ 150.5
500+
2 │ B │ 200.0
501+
4 │ C │ 400.0
502+
└──────────────────────────────────────────────┘
503+
```
504+
505+
#### Multi-Field Partitioned Table
506+
507+
```sql
508+
CREATE TABLE t_multi_part(id INT, region STRING, year INT, amount DOUBLE)
509+
ENGINE = ICEBERG
510+
PARTITION BY (region, year);
511+
512+
INSERT INTO t_multi_part VALUES
513+
(1, 'US', 2023, 100.5),
514+
(2, 'EU', 2023, 200.5),
515+
(3, 'US', 2024, 300.5),
516+
(4, 'EU', 2024, 400.5);
517+
518+
-- Insert into existing partitions
519+
INSERT INTO t_multi_part VALUES
520+
(5, 'US', 2023, 500.5);
521+
522+
-- Null values in partition columns are supported
523+
INSERT INTO t_multi_part VALUES
524+
(6, NULL, 2023, 600.5),
525+
(7, 'US', NULL, 700.5);
526+
527+
SELECT * FROM t_multi_part;
528+
529+
┌──────────────────────────────────────────────────────┐
530+
│ id │ region │ year │ amount │
531+
├────────┼──────────┼──────────┼───────────────────────┤
532+
1 │ US │ 2023100.5
533+
5 │ US │ 2023500.5
534+
3 │ US │ 2024300.5
535+
2 │ EU │ 2023200.5
536+
4 │ EU │ 2024400.5
537+
6NULL2023600.5
538+
7 │ US │ NULL700.5
539+
└──────────────────────────────────────────────────────┘
540+
```
541+
419542
## Apache Iceberg™ Table Functions
420543

421544
Databend provides the following table functions for querying Iceberg metadata, allowing users to inspect snapshots and manifests efficiently:

0 commit comments

Comments
 (0)