Skip to content

Appender: support nested lists and maps (1.4)#408

Merged
staticlibs merged 1 commit intoduckdb:v1.4-andiumfrom
staticlibs:appender_lists2_14
Oct 3, 2025
Merged

Appender: support nested lists and maps (1.4)#408
staticlibs merged 1 commit intoduckdb:v1.4-andiumfrom
staticlibs:appender_lists2_14

Conversation

@staticlibs
Copy link
Collaborator

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

This PR adds support for appending to MAP and composite LIST columns, for example LIST of STRUCTs, LIST of ARRAYs or nested LISTs.

It should cover virtually any table schema with composite fields, with the notable exception of ARRAYs with more than 2 dimensions (like INT[2][3][4]) - only 2D ARRAYs are supported. Higher dimensions could be possible, but the interface for them appeared to be tough to generalize. LISTs of ARRAYs can be used instead, like INT[2][3][].

LISTs can be specified as a Collection or Iterator (with count) of objects.

MAPs are specified as java.util.Map instances.

STRUCT inside a LIST can be specified either as java.utils.LinkedHashMap (keys are ignored) or as a Collection of values for STRUCT fields.

UNION inside a LIST can be specified as an instance of java.util.AbstractMap.SimpleEntry, where a key is used as a tag to choose which UNION field to append to.

If some required input cases are missed - please raise an issue.

Testing: new tests added to cover various combinations of nesting.

Fixes: #307, #344

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

This PR adds support for appending to `MAP` and composite `LIST`
columns, for example `LIST` of `STRUCT`s, `LIST` of `ARRAY`s or
nested `LIST`s.

It should cover virtually any table schema with composite fields, with
the notable exception of `ARRAY`s with more than 2 dimensions (like
`INT[2][3][4]`) - only 2D `ARRAY`s are supported. Higher dimensions
could be possible, but the interface for them appeared to be tough to
generalize. `LIST`s of `ARRAY`s can be used instead, like `INT[2][3][]`.

`LIST`s can be specified as a `Collection` or `Iterator` (with `count`)
of objects.

`MAP`s are specified as `java.util.Map` instances.

`STRUCT` inside a `LIST` can be specified either as
`java.utils.LinkedHashMap` (keys are ignored) or as a `Collection` of
values for `STRUCT` fields.

`UNION` inside a `LIST` can be specified as an instance of
`java.util.AbstractMap.SimpleEntry`, where a `key` is used as a tag to
choose which `UNION` field to append to.

If some required input cases are missed - please raise an issue.

Testing: new tests added to cover various combinations of nesting.
@staticlibs staticlibs merged commit 9469b52 into duckdb:v1.4-andium Oct 3, 2025
@staticlibs staticlibs deleted the appender_lists2_14 branch October 3, 2025 17:53
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