Skip to content

Commit 420fd9b

Browse files
committed
feat: Add support for Iceberg2 database type and related configurations
- Introduced TypeDbIceberg2 in dbio_types.go to support Iceberg2 database. - Added Iceberg2 template in iceberg2.yaml with necessary SQL commands and metadata queries. - Updated types_general_to_native.tsv and types_native_to_general.tsv to include Iceberg2 data types and mappings. - Modified config.go to handle temporary table creation for Iceberg2, DuckDB, and DuckLake.
1 parent 0ae3fc1 commit 420fd9b

10 files changed

Lines changed: 997 additions & 67 deletions

File tree

cmd/sling/tests/replications/r.23.iceberg_write.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ target: '{target}'
33

44
hooks:
55
end:
6-
# does not work for gcp or sql
6+
# does not work for gcp or sql or glue (original iceberg connector only)
77
- type: check
88
id: target_check
9-
check: lower(target.name) != "iceberg_gcp" && lower(target.name) != "iceberg_sql"&& lower(target.name) != "iceberg_glue"
9+
check: lower(target.name) != "iceberg_gcp" && lower(target.name) != "iceberg_sql" && lower(target.name) != "iceberg_glue"
1010
failure_message: skipping target {target.name}
1111
on_failure: break
12-
12+
1313
# verify that we can query with custom SQL via duckDB
14+
# For iceberg (original), use iceberg_catalog.public.test1k_mariadb_pg
15+
# For iceberg2, the default catalog is already 'iceberg', so just use public.test1k_mariadb_pg
1416
- type: query
1517
connection: '{target}'
16-
query: select count(*) from iceberg_catalog.public.test1k_mariadb_pg
18+
query: select count(*) as count_star from {env.catalog_table}
1719
into: count_result
18-
20+
1921
- type: log
2022
message: 'count_result => { store.count_result[0] }'
2123

@@ -33,4 +35,5 @@ streams:
3335

3436
env:
3537
target: ${TARGET}
38+
catalog_table: ${catalog_table}
3639

cmd/sling/tests/suite.cli.yaml

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,12 @@
515515
sling run --src-conn $TARGET --src-stream public.test1k_mariadb_pg --stdout -l 5
516516
env:
517517
TARGET: iceberg_r2
518+
catalog_table: public.test1k_mariadb_pg # iceberg2 uses 'iceberg' as default catalog
518519
streams: 2
519520
output_contains:
520-
- committed iceberg snapshot
521-
- count_result => {"count_star":1001}
522-
- inserted 967 rows
523-
521+
- count_result => {"count_star":1003}
522+
- inserted 969 rows
523+
524524
# part of stdout output
525525
- writing to target stream (stdout)
526526
- wrote 5 rows
@@ -532,13 +532,13 @@
532532
sling run --src-conn $TARGET --src-stream public.test1k_mariadb_pg --stdout -l 5
533533
env:
534534
TARGET: iceberg_s3
535+
catalog_table: public.test1k_mariadb_pg # iceberg2 uses 'iceberg' as default catalog
535536
after: [74]
536537
streams: 2
537538
output_contains:
538-
- committed iceberg snapshot
539-
- count_result => {"count_star":1001}
540-
- inserted 967 rows
541-
539+
- count_result => {"count_star":1003}
540+
- inserted 969 rows
541+
542542
# part of stdout output
543543
- writing to target stream (stdout)
544544
- wrote 5 rows
@@ -560,39 +560,26 @@
560560
# - writing to target stream (stdout)
561561
# - wrote 5 rows
562562

563-
- id: 77
564-
name: Run sling iceberg_sql insert
565-
run: |
566-
sling run -d -r cmd/sling/tests/replications/r.23.iceberg_write.yaml
567-
sling run --src-conn $TARGET --src-stream public.test1k_mariadb_pg --stdout -l 5
568-
env:
569-
TARGET: iceberg_sql
570-
after: [75]
571-
streams: 2
572-
output_contains:
573-
- committed iceberg snapshot
574-
- inserted 967 rows
575-
576-
# part of stdout output
577-
- writing to target stream (stdout)
578-
- wrote 5 rows
563+
# Test 78 DISABLED: DuckDB Iceberg extension bug - CREATE TABLE fails with Glue catalog
564+
# Error: "Cannot parse missing string: location" (Glue requires location parameter, DuckDB doesn't send it)
565+
# Upstream issue: https://github.com/duckdb/duckdb-iceberg/issues/549
566+
# - id: 78
567+
# name: Run sling iceberg_glue insert
568+
# run: |
569+
# sling run -d -r cmd/sling/tests/replications/r.23.iceberg_write.yaml
570+
# sling run --src-conn $TARGET --src-stream public.test1k_mariadb_pg --stdout -l 5
571+
# env:
572+
# TARGET: iceberg_glue
573+
# catalog_table: public.test1k_mariadb_pg
574+
# after: [75]
575+
# streams: 2
576+
# output_contains:
577+
# - count_result => {"count_star":1003}
578+
# - inserted 969 rows
579579

580-
- id: 78
581-
name: Run sling iceberg_glue insert
582-
run: |
583-
sling run -d -r cmd/sling/tests/replications/r.23.iceberg_write.yaml
584-
sling run --src-conn $TARGET --src-stream public.test1k_mariadb_pg --stdout -l 5
585-
env:
586-
TARGET: iceberg_glue
587-
after: [77]
588-
streams: 2
589-
output_contains:
590-
- committed iceberg snapshot
591-
- inserted 967 rows
592-
593-
# part of stdout output
594-
- writing to target stream (stdout)
595-
- wrote 5 rows
580+
# # part of stdout output
581+
# - writing to target stream (stdout)
582+
# - wrote 5 rows
596583

597584
# - id: 79
598585
# name: Run sling iceberg_gcp insert

core/dbio/connection/connection.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,43 @@ func (c *Connection) setURL() (err error) {
10091009
}
10101010

10111011
template = "iceberg://{catalog_type}"
1012+
case dbio.TypeDbIceberg2:
1013+
setIfMissing("catalog_type", c.Data["catalog_type"]) // rest, glue, s3tables
1014+
setIfMissing("catalog_name", "iceberg")
1015+
1016+
// REST catalog properties
1017+
setIfMissing("rest_uri", c.Data["rest_uri"])
1018+
setIfMissing("rest_warehouse", c.Data["rest_warehouse"])
1019+
setIfMissing("rest_token", c.Data["rest_token"])
1020+
setIfMissing("rest_oauth_client_id", c.Data["rest_oauth_client_id"])
1021+
setIfMissing("rest_oauth_client_secret", c.Data["rest_oauth_client_secret"])
1022+
setIfMissing("rest_oauth_server_uri", c.Data["rest_oauth_server_uri"])
1023+
setIfMissing("rest_oauth_scope", c.Data["rest_oauth_scope"])
1024+
1025+
// Glue catalog properties
1026+
setIfMissing("glue_account_id", c.Data["glue_account_id"])
1027+
setIfMissing("glue_region", c.Data["glue_region"])
1028+
1029+
// S3 Tables properties
1030+
setIfMissing("s3_tables_arn", c.Data["s3_tables_arn"])
1031+
1032+
// S3 storage credentials
1033+
setIfMissing("s3_access_key_id", c.Data["s3_access_key_id"])
1034+
setIfMissing("s3_secret_access_key", c.Data["s3_secret_access_key"])
1035+
setIfMissing("s3_region", c.Data["s3_region"])
1036+
setIfMissing("s3_session_token", c.Data["s3_session_token"])
1037+
setIfMissing("s3_endpoint", c.Data["s3_endpoint"])
1038+
1039+
// Azure storage credentials
1040+
setIfMissing("azure_account_name", c.Data["azure_account_name"])
1041+
setIfMissing("azure_account_key", c.Data["azure_account_key"])
1042+
setIfMissing("azure_sas_token", c.Data["azure_sas_token"])
1043+
1044+
// GCS storage credentials
1045+
setIfMissing("gcs_access_key_id", c.Data["gcs_access_key_id"])
1046+
setIfMissing("gcs_secret_access_key", c.Data["gcs_secret_access_key"])
1047+
1048+
template = "iceberg2://{catalog_type}"
10121049
case dbio.TypeDbAthena:
10131050
// use dbt inputs
10141051
{

core/dbio/database/database.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ func NewConnContext(ctx context.Context, URL string, props ...string) (Connectio
312312
conn = &DuckDbConn{URL: URL}
313313
} else if strings.HasPrefix(URL, "ducklake:") {
314314
conn = &DuckLakeConn{DuckDbConn: DuckDbConn{URL: URL}}
315+
} else if strings.HasPrefix(URL, "iceberg2:") {
316+
conn = &Iceberg2Conn{DuckDbConn: DuckDbConn{URL: URL}}
315317
} else if strings.HasPrefix(URL, "iceberg:") {
316318
conn = &IcebergConn{URL: URL}
317319
} else if strings.HasPrefix(URL, "azuretable:") {

0 commit comments

Comments
 (0)