Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UTF8 in nested Apache Arrow data types (e.g. List) #300

Merged
merged 7 commits into from
Apr 24, 2024

Conversation

Jeadie
Copy link
Contributor

@Jeadie Jeadie commented Apr 24, 2024

Changes

  • Currently only primitive nested types are supported
  • Add support for ListArray with nested UTF8 type

Illustrative Example

let mut stmt = db.prepare(format!(r#"CREATE TABLE "{name}" AS SELECT * FROM arrow(?, ?);"#).as_str()).unwrap();

// [["foo", "baz"], ["bar", "foo"], ["baz"]]
let list_array: ArrayRef = Arc::new(ListArray::new(
    Arc::new(Field::new("item", DataType::Utf8, true)),
    OffsetBuffer::new(ScalarBuffer::from(vec![0, 2, 4, 5])), 
    Arc::new(StringArray::from(vec![Some("foo"), Some("baz"), Some("bar"), Some("foo"), Some("baz")])), None)
);

let b: Result<RecordBatch, arrow::error::ArrowError> = RecordBatch::try_from_iter(vec![("my_col", list_array)]); 
stmt.execute(arrow_recordbatch_to_query_params(
    RecordBatch::try_from_iter(vec![("col_name", list_array)])?)
);

@Mause
Copy link
Member

Mause commented Apr 24, 2024

Can you add a test please?

@Jeadie
Copy link
Contributor Author

Jeadie commented Apr 24, 2024

Will do

@Maxxen Maxxen merged commit 5a1729e into duckdb:main Apr 24, 2024
4 checks passed
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.

None yet

4 participants