Skip to content

Appender: support composite/nested lists and maps#399

Merged
staticlibs merged 1 commit intoduckdb:mainfrom
staticlibs:appender_lists2
Sep 25, 2025
Merged

Appender: support composite/nested lists and maps#399
staticlibs merged 1 commit intoduckdb:mainfrom
staticlibs:appender_lists2

Conversation

@staticlibs
Copy link
Collaborator

@staticlibs staticlibs commented Sep 24, 2025

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][].

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

MAPs can be 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 missing - please raise an issue.

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

Fixes: #307, #344

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 15d491a into duckdb:main Sep 25, 2025
9 checks passed
@staticlibs staticlibs deleted the appender_lists2 branch September 25, 2025 17:13
staticlibs added a commit to staticlibs/duckdb-java that referenced this pull request Oct 3, 2025
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 added a commit that referenced this pull request Oct 3, 2025
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 `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.
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.

[Appender] Add support for MAP and UNION

1 participant