Skip to content

Appender UNION support (1.4)#382

Merged
staticlibs merged 1 commit intoduckdb:v1.4-andiumfrom
staticlibs:appender_union_14
Sep 15, 2025
Merged

Appender UNION support (1.4)#382
staticlibs merged 1 commit intoduckdb:v1.4-andiumfrom
staticlibs:appender_union_14

Conversation

@staticlibs
Copy link
Collaborator

This is a backport of the PR #372 to v1.4-andium stable branch.

This PR adds support for appending data to UNION columns. The tag (field name) of the union must be specified in beginUnion() call before appending the actual value.

Nested unions (or structs inside unions) are not supported.

Example:

CREATE TABLE tab1 (col1 INTEGER, col2 UNION(u1 INTEGER, u2 VARCHAR))
DuckDBAppender appender = conn.createAppender("tab1");

// append row with INTEGER value in UNION
appender
    .beginRow()
    .append(1)
    .beginUnion("u1")
    .append(42)
    .endUnion()
    .endRow();

// append row with VARCHAR value in UNION
appender
    .beginRow()
    .append(2)
    .beginUnion("u2")
    .append("foo")
    .endUnion()
    .endRow();

Testing: existing test is extended to cover UNIONs.

This is a backport of the PR duckdb#372 to `v1.4-andium` stable branch.

This PR adds support for appending data to `UNION` columns. The tag
(field name) of the union must be specified in `beginUnion()` call
before appending the actual value.

Nested unions (or structs inside unions) are not supported.

Example:

```sql
CREATE TABLE tab1 (col1 INTEGER, col2 UNION(u1 INTEGER, u2 VARCHAR))
```

```java
DuckDBAppender appender = conn.createAppender("tab1");

// append row with INTEGER value in UNION
appender
    .beginRow()
    .append(1)
    .beginUnion("u1")
    .append(42)
    .endUnion()
    .endRow();

// append row with VARCHAR value in UNION
appender
    .beginRow()
    .append(2)
    .beginUnion("u2")
    .append("foo")
    .endUnion()
    .endRow();
```

Testing: existing test is extended to cover `UNION`s.
@staticlibs staticlibs merged commit cbfbe2c into duckdb:v1.4-andium Sep 15, 2025
@staticlibs staticlibs deleted the appender_union_14 branch September 15, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant