You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "codephage2020 (via GitHub)" <gi...@apache.org> on 2026/02/04 08:52:24 UTC

[PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

codephage2020 opened a new pull request, #9352:
URL: https://github.com/apache/arrow-rs/pull/9352

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
   -->
   
   - Closes #9344 .
   
   # Rationale for this change
   
   This PR implements support for roundtrip reading and writing of ListView and LargeListView types in Parquet Arrow integration.
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   - Handle ListView/LargeListView in Arrow ↔ Parquet schema conversion
   - Reader/Writer support 
   - Added some tests
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   YES
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   
   If there are any breaking changes to public APIs, please call them out.
   -->
   Users can now write and read ListView/LargeListView arrays to/from Parquet files


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "codephage2020 (via GitHub)" <gi...@apache.org>.
codephage2020 commented on code in PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352#discussion_r2772116383


##########
parquet/src/arrow/array_reader/list_view_array.rs:
##########
@@ -0,0 +1,249 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::arrow::array_reader::{ArrayReader, ListArrayReader};
+use crate::errors::Result;
+use arrow_array::{
+    Array, ArrayRef, GenericListArray, GenericListViewArray, OffsetSizeTrait, new_empty_array,
+};
+use arrow_schema::DataType as ArrowType;
+use std::any::Any;
+use std::sync::Arc;
+
+/// Implementation of list view array reader.
+/// This wraps a ListArrayReader and converts the result to ListViewArray.
+pub struct ListViewArrayReader<OffsetSize: OffsetSizeTrait> {
+    inner: ListArrayReader<OffsetSize>,
+    data_type: ArrowType,
+}
+
+impl<OffsetSize: OffsetSizeTrait> ListViewArrayReader<OffsetSize> {
+    /// Construct list view array reader.
+    pub fn new(
+        item_reader: Box<dyn ArrayReader>,
+        data_type: ArrowType,
+        def_level: i16,
+        rep_level: i16,
+        nullable: bool,
+    ) -> Self {
+        // Create the underlying ListArrayReader with the corresponding List type
+        let list_data_type = match &data_type {
+            ArrowType::ListView(f) => ArrowType::List(f.clone()),
+            ArrowType::LargeListView(f) => ArrowType::LargeList(f.clone()),
+            _ => unreachable!(),
+        };

Review Comment:
   The conversion here is to reuse ListArrayReader for handling complex Dremel level calculations. Internally, ListArrayReader can only handle List or LargeList types and cannot handle ListView types



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352#discussion_r2771960821


##########
parquet/src/arrow/array_reader/list_view_array.rs:
##########
@@ -0,0 +1,249 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::arrow::array_reader::{ArrayReader, ListArrayReader};
+use crate::errors::Result;
+use arrow_array::{
+    Array, ArrayRef, GenericListArray, GenericListViewArray, OffsetSizeTrait, new_empty_array,
+};
+use arrow_schema::DataType as ArrowType;
+use std::any::Any;
+use std::sync::Arc;
+
+/// Implementation of list view array reader.
+/// This wraps a ListArrayReader and converts the result to ListViewArray.
+pub struct ListViewArrayReader<OffsetSize: OffsetSizeTrait> {
+    inner: ListArrayReader<OffsetSize>,
+    data_type: ArrowType,
+}
+
+impl<OffsetSize: OffsetSizeTrait> ListViewArrayReader<OffsetSize> {
+    /// Construct list view array reader.
+    pub fn new(
+        item_reader: Box<dyn ArrayReader>,
+        data_type: ArrowType,
+        def_level: i16,
+        rep_level: i16,
+        nullable: bool,
+    ) -> Self {
+        // Create the underlying ListArrayReader with the corresponding List type
+        let list_data_type = match &data_type {
+            ArrowType::ListView(f) => ArrowType::List(f.clone()),
+            ArrowType::LargeListView(f) => ArrowType::LargeList(f.clone()),
+            _ => unreachable!(),
+        };
+
+        let inner =
+            ListArrayReader::new(item_reader, list_data_type, def_level, rep_level, nullable);
+
+        Self { inner, data_type }
+    }
+}
+
+impl<OffsetSize: OffsetSizeTrait> ArrayReader for ListViewArrayReader<OffsetSize> {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    /// Returns data type.
+    /// This must be a ListView.
+    fn get_data_type(&self) -> &ArrowType {
+        &self.data_type
+    }
+
+    fn read_records(&mut self, batch_size: usize) -> Result<usize> {
+        self.inner.read_records(batch_size)
+    }
+
+    fn consume_batch(&mut self) -> Result<ArrayRef> {
+        let array = self.inner.consume_batch()?;
+        if array.is_empty() {
+            return Ok(new_empty_array(&self.data_type));
+        }
+
+        // Convert ListArray to ListViewArray
+        let list_array = array
+            .as_any()
+            .downcast_ref::<GenericListArray<OffsetSize>>()
+            .expect("ListViewArrayReader: inner reader must return GenericListArray");

Review Comment:
   ```suggestion
           use arrow_array::cast::AsArray;
           let list_array = array.as_list::<OffsetSize>();
   ```
   
   - Can move the use to top of file



##########
parquet/src/arrow/array_reader/list_view_array.rs:
##########
@@ -0,0 +1,249 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::arrow::array_reader::{ArrayReader, ListArrayReader};
+use crate::errors::Result;
+use arrow_array::{
+    Array, ArrayRef, GenericListArray, GenericListViewArray, OffsetSizeTrait, new_empty_array,
+};
+use arrow_schema::DataType as ArrowType;
+use std::any::Any;
+use std::sync::Arc;
+
+/// Implementation of list view array reader.
+/// This wraps a ListArrayReader and converts the result to ListViewArray.
+pub struct ListViewArrayReader<OffsetSize: OffsetSizeTrait> {
+    inner: ListArrayReader<OffsetSize>,
+    data_type: ArrowType,
+}
+
+impl<OffsetSize: OffsetSizeTrait> ListViewArrayReader<OffsetSize> {
+    /// Construct list view array reader.
+    pub fn new(
+        item_reader: Box<dyn ArrayReader>,
+        data_type: ArrowType,
+        def_level: i16,
+        rep_level: i16,
+        nullable: bool,
+    ) -> Self {
+        // Create the underlying ListArrayReader with the corresponding List type
+        let list_data_type = match &data_type {
+            ArrowType::ListView(f) => ArrowType::List(f.clone()),
+            ArrowType::LargeListView(f) => ArrowType::LargeList(f.clone()),
+            _ => unreachable!(),
+        };

Review Comment:
   I think we can pass as is without destructuring -> structuring datatype again



##########
parquet/src/arrow/array_reader/list_view_array.rs:
##########
@@ -0,0 +1,249 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::arrow::array_reader::{ArrayReader, ListArrayReader};
+use crate::errors::Result;
+use arrow_array::{
+    Array, ArrayRef, GenericListArray, GenericListViewArray, OffsetSizeTrait, new_empty_array,
+};
+use arrow_schema::DataType as ArrowType;
+use std::any::Any;
+use std::sync::Arc;
+
+/// Implementation of list view array reader.
+/// This wraps a ListArrayReader and converts the result to ListViewArray.
+pub struct ListViewArrayReader<OffsetSize: OffsetSizeTrait> {
+    inner: ListArrayReader<OffsetSize>,
+    data_type: ArrowType,
+}
+
+impl<OffsetSize: OffsetSizeTrait> ListViewArrayReader<OffsetSize> {
+    /// Construct list view array reader.
+    pub fn new(
+        item_reader: Box<dyn ArrayReader>,
+        data_type: ArrowType,
+        def_level: i16,
+        rep_level: i16,
+        nullable: bool,
+    ) -> Self {
+        // Create the underlying ListArrayReader with the corresponding List type
+        let list_data_type = match &data_type {
+            ArrowType::ListView(f) => ArrowType::List(f.clone()),
+            ArrowType::LargeListView(f) => ArrowType::LargeList(f.clone()),
+            _ => unreachable!(),
+        };
+
+        let inner =
+            ListArrayReader::new(item_reader, list_data_type, def_level, rep_level, nullable);
+
+        Self { inner, data_type }
+    }
+}
+
+impl<OffsetSize: OffsetSizeTrait> ArrayReader for ListViewArrayReader<OffsetSize> {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    /// Returns data type.
+    /// This must be a ListView.
+    fn get_data_type(&self) -> &ArrowType {
+        &self.data_type
+    }
+
+    fn read_records(&mut self, batch_size: usize) -> Result<usize> {
+        self.inner.read_records(batch_size)
+    }
+
+    fn consume_batch(&mut self) -> Result<ArrayRef> {
+        let array = self.inner.consume_batch()?;
+        if array.is_empty() {
+            return Ok(new_empty_array(&self.data_type));
+        }
+
+        // Convert ListArray to ListViewArray
+        let list_array = array
+            .as_any()
+            .downcast_ref::<GenericListArray<OffsetSize>>()
+            .expect("ListViewArrayReader: inner reader must return GenericListArray");
+
+        let list_view_array =
+            Arc::new(GenericListViewArray::<OffsetSize>::from(list_array.clone()));

Review Comment:
   I suppose this is the easiest way to do this for now; maybe in followup we can explore ways to read directly into listview without going through a listarray, if there is potential performance benefit 👍 



##########
parquet/src/arrow/arrow_writer/mod.rs:
##########
@@ -1734,6 +1736,120 @@ mod tests {
         roundtrip(batch, None);
     }
 
+    #[test]
+    fn arrow_writer_list_view() {
+        let list_field = Arc::new(Field::new_list_field(DataType::Int32, false));
+        let schema = Schema::new(vec![Field::new(
+            "a",
+            DataType::ListView(list_field.clone()),
+            true,
+        )]);
+
+        //  [[1], [2, 3], null, [4, 5, 6], [7, 8, 9, 10]]
+        let a = ListViewArray::new(
+            list_field,
+            vec![0, 1, 0, 3, 6].into(),
+            vec![1, 2, 0, 3, 4].into(),
+            Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10])),
+            Some(vec![true, true, false, true, true].into()),
+        );
+
+        let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)]).unwrap();
+
+        assert_eq!(batch.column(0).null_count(), 1);
+
+        roundtrip(batch, None);
+    }
+
+    #[test]
+    fn arrow_writer_list_view_non_null() {
+        let list_field = Arc::new(Field::new_list_field(DataType::Int32, false));
+        let schema = Schema::new(vec![Field::new(
+            "a",
+            DataType::ListView(list_field.clone()),
+            false,
+        )]);
+
+        //  [[1], [2, 3], [], [4, 5, 6], [7, 8, 9, 10]]
+        let a = ListViewArray::new(
+            list_field,
+            vec![0, 1, 0, 3, 6].into(),
+            vec![1, 2, 0, 3, 4].into(),

Review Comment:
   Perhaps can change this test case to have offset out of order for non-zero size? e.g.
   
   ```rust
   // [[1], [2, 3], [], [7, 8, 9, 10], [4, 5, 6]]
   let a = ListViewArray::new(
       list_field,
       vec![0, 1, 0, 6, 3].into(),
       vec![1, 2, 0, 4, 3].into(),
       Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10])),
       None,
   );
   ```
   
   Just to verify roundtrip works for list views like these



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352#discussion_r2772119624


##########
parquet/src/arrow/array_reader/list_view_array.rs:
##########
@@ -0,0 +1,249 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::arrow::array_reader::{ArrayReader, ListArrayReader};
+use crate::errors::Result;
+use arrow_array::{
+    Array, ArrayRef, GenericListArray, GenericListViewArray, OffsetSizeTrait, new_empty_array,
+};
+use arrow_schema::DataType as ArrowType;
+use std::any::Any;
+use std::sync::Arc;
+
+/// Implementation of list view array reader.
+/// This wraps a ListArrayReader and converts the result to ListViewArray.
+pub struct ListViewArrayReader<OffsetSize: OffsetSizeTrait> {
+    inner: ListArrayReader<OffsetSize>,
+    data_type: ArrowType,
+}
+
+impl<OffsetSize: OffsetSizeTrait> ListViewArrayReader<OffsetSize> {
+    /// Construct list view array reader.
+    pub fn new(
+        item_reader: Box<dyn ArrayReader>,
+        data_type: ArrowType,
+        def_level: i16,
+        rep_level: i16,
+        nullable: bool,
+    ) -> Self {
+        // Create the underlying ListArrayReader with the corresponding List type
+        let list_data_type = match &data_type {
+            ArrowType::ListView(f) => ArrowType::List(f.clone()),
+            ArrowType::LargeListView(f) => ArrowType::LargeList(f.clone()),
+            _ => unreachable!(),
+        };

Review Comment:
   Ah yes my mistake, I didn't read the code properly here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "codephage2020 (via GitHub)" <gi...@apache.org>.
codephage2020 commented on code in PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352#discussion_r2772125073


##########
parquet/src/arrow/arrow_writer/mod.rs:
##########
@@ -1734,6 +1736,120 @@ mod tests {
         roundtrip(batch, None);
     }
 
+    #[test]
+    fn arrow_writer_list_view() {
+        let list_field = Arc::new(Field::new_list_field(DataType::Int32, false));
+        let schema = Schema::new(vec![Field::new(
+            "a",
+            DataType::ListView(list_field.clone()),
+            true,
+        )]);
+
+        //  [[1], [2, 3], null, [4, 5, 6], [7, 8, 9, 10]]
+        let a = ListViewArray::new(
+            list_field,
+            vec![0, 1, 0, 3, 6].into(),
+            vec![1, 2, 0, 3, 4].into(),
+            Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10])),
+            Some(vec![true, true, false, true, true].into()),
+        );
+
+        let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)]).unwrap();
+
+        assert_eq!(batch.column(0).null_count(), 1);
+
+        roundtrip(batch, None);
+    }
+
+    #[test]
+    fn arrow_writer_list_view_non_null() {
+        let list_field = Arc::new(Field::new_list_field(DataType::Int32, false));
+        let schema = Schema::new(vec![Field::new(
+            "a",
+            DataType::ListView(list_field.clone()),
+            false,
+        )]);
+
+        //  [[1], [2, 3], [], [4, 5, 6], [7, 8, 9, 10]]
+        let a = ListViewArray::new(
+            list_field,
+            vec![0, 1, 0, 3, 6].into(),
+            vec![1, 2, 0, 3, 4].into(),

Review Comment:
   I will add a new test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "codephage2020 (via GitHub)" <gi...@apache.org>.
codephage2020 commented on PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352#issuecomment-3857305550

   CC @alamb @Jefffrey 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "codephage2020 (via GitHub)" <gi...@apache.org>.
codephage2020 commented on code in PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352#discussion_r2772117195


##########
parquet/src/arrow/array_reader/list_view_array.rs:
##########
@@ -0,0 +1,249 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::arrow::array_reader::{ArrayReader, ListArrayReader};
+use crate::errors::Result;
+use arrow_array::{
+    Array, ArrayRef, GenericListArray, GenericListViewArray, OffsetSizeTrait, new_empty_array,
+};
+use arrow_schema::DataType as ArrowType;
+use std::any::Any;
+use std::sync::Arc;
+
+/// Implementation of list view array reader.
+/// This wraps a ListArrayReader and converts the result to ListViewArray.
+pub struct ListViewArrayReader<OffsetSize: OffsetSizeTrait> {
+    inner: ListArrayReader<OffsetSize>,
+    data_type: ArrowType,
+}
+
+impl<OffsetSize: OffsetSizeTrait> ListViewArrayReader<OffsetSize> {
+    /// Construct list view array reader.
+    pub fn new(
+        item_reader: Box<dyn ArrayReader>,
+        data_type: ArrowType,
+        def_level: i16,
+        rep_level: i16,
+        nullable: bool,
+    ) -> Self {
+        // Create the underlying ListArrayReader with the corresponding List type
+        let list_data_type = match &data_type {
+            ArrowType::ListView(f) => ArrowType::List(f.clone()),
+            ArrowType::LargeListView(f) => ArrowType::LargeList(f.clone()),
+            _ => unreachable!(),
+        };
+
+        let inner =
+            ListArrayReader::new(item_reader, list_data_type, def_level, rep_level, nullable);
+
+        Self { inner, data_type }
+    }
+}
+
+impl<OffsetSize: OffsetSizeTrait> ArrayReader for ListViewArrayReader<OffsetSize> {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    /// Returns data type.
+    /// This must be a ListView.
+    fn get_data_type(&self) -> &ArrowType {
+        &self.data_type
+    }
+
+    fn read_records(&mut self, batch_size: usize) -> Result<usize> {
+        self.inner.read_records(batch_size)
+    }
+
+    fn consume_batch(&mut self) -> Result<ArrayRef> {
+        let array = self.inner.consume_batch()?;
+        if array.is_empty() {
+            return Ok(new_empty_array(&self.data_type));
+        }
+
+        // Convert ListArray to ListViewArray
+        let list_array = array
+            .as_any()
+            .downcast_ref::<GenericListArray<OffsetSize>>()
+            .expect("ListViewArrayReader: inner reader must return GenericListArray");

Review Comment:
   nice



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352#issuecomment-3874749873

   Thanks @codephage2020 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Support roundtrip ListView in parquet arrow writer [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #9352:
URL: https://github.com/apache/arrow-rs/pull/9352


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org