liurenjie1024 commented on code in PR #731:
URL: https://github.com/apache/iceberg-rust/pull/731#discussion_r1872521649


##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -0,0 +1,874 @@
+// 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 arrow_array::{
+    Array, BinaryArray, BooleanArray, Date32Array, Decimal128Array, 
Float32Array, Float64Array,
+    Int16Array, Int32Array, Int64Array, LargeBinaryArray, LargeStringArray, 
NullArray, StringArray,
+    StructArray, Time64MicrosecondArray, TimestampMicrosecondArray, 
TimestampNanosecondArray,
+};
+use arrow_schema::{DataType, TimeUnit};
+use itertools::Itertools;
+
+use crate::spec::{Literal, PrimitiveType, Struct, StructType, Type};
+use crate::{Error, ErrorKind, Result};
+
+trait ArrowArrayVistor {

Review Comment:
   We need have clear documentation about what kind of visitor it is. Is it an 
post order visitor?



##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -0,0 +1,874 @@
+// 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 arrow_array::{
+    Array, BinaryArray, BooleanArray, Date32Array, Decimal128Array, 
Float32Array, Float64Array,
+    Int16Array, Int32Array, Int64Array, LargeBinaryArray, LargeStringArray, 
NullArray, StringArray,
+    StructArray, Time64MicrosecondArray, TimestampMicrosecondArray, 
TimestampNanosecondArray,
+};
+use arrow_schema::{DataType, TimeUnit};
+use itertools::Itertools;
+
+use crate::spec::{Literal, PrimitiveType, Struct, StructType, Type};
+use crate::{Error, ErrorKind, Result};
+
+trait ArrowArrayVistor {
+    type T;
+    fn null(
+        &self,
+        array: &NullArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,

Review Comment:
   I also don't think we need an `arrow_type`, arrow array has data type 
associated with it: 
https://docs.rs/arrow/latest/arrow/array/trait.Array.html#tymethod.data_type



##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -0,0 +1,874 @@
+// 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 arrow_array::{
+    Array, BinaryArray, BooleanArray, Date32Array, Decimal128Array, 
Float32Array, Float64Array,
+    Int16Array, Int32Array, Int64Array, LargeBinaryArray, LargeStringArray, 
NullArray, StringArray,
+    StructArray, Time64MicrosecondArray, TimestampMicrosecondArray, 
TimestampNanosecondArray,
+};
+use arrow_schema::{DataType, TimeUnit};
+use itertools::Itertools;
+
+use crate::spec::{Literal, PrimitiveType, Struct, StructType, Type};
+use crate::{Error, ErrorKind, Result};
+
+trait ArrowArrayVistor {
+    type T;
+    fn null(
+        &self,
+        array: &NullArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,

Review Comment:
   I'm hesitating to add an `iceberg_type` here.



##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -0,0 +1,874 @@
+// 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 arrow_array::{
+    Array, BinaryArray, BooleanArray, Date32Array, Decimal128Array, 
Float32Array, Float64Array,
+    Int16Array, Int32Array, Int64Array, LargeBinaryArray, LargeStringArray, 
NullArray, StringArray,
+    StructArray, Time64MicrosecondArray, TimestampMicrosecondArray, 
TimestampNanosecondArray,
+};
+use arrow_schema::{DataType, TimeUnit};
+use itertools::Itertools;
+
+use crate::spec::{Literal, PrimitiveType, Struct, StructType, Type};
+use crate::{Error, ErrorKind, Result};
+
+trait ArrowArrayVistor {
+    type T;
+    fn null(
+        &self,
+        array: &NullArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn boolean(
+        &self,
+        array: &BooleanArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn int16(
+        &self,
+        array: &Int16Array,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn int32(
+        &self,
+        array: &Int32Array,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn int64(
+        &self,
+        array: &Int64Array,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn float(
+        &self,
+        array: &Float32Array,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn double(
+        &self,
+        array: &Float64Array,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn decimal(
+        &self,
+        array: &Decimal128Array,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn date(
+        &self,
+        array: &Date32Array,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn time(
+        &self,
+        array: &Time64MicrosecondArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn timestamp(
+        &self,
+        array: &TimestampMicrosecondArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn timestamp_nano(
+        &self,
+        array: &TimestampNanosecondArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn string(
+        &self,
+        array: &StringArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn large_string(
+        &self,
+        array: &LargeStringArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn binary(
+        &self,
+        array: &BinaryArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn large_binary(
+        &self,
+        array: &LargeBinaryArray,
+        arrow_type: &DataType,
+        iceberg_type: &PrimitiveType,
+    ) -> Result<Vec<Self::T>>;
+    fn combine_struct(
+        &self,
+        array: &StructArray,
+        columns: Vec<Vec<Self::T>>,
+    ) -> Result<Vec<Self::T>>;
+    fn r#struct(

Review Comment:
   The implementation of this method is somehow weird to me, since it's 
actually implementing the visiting scheduler logic, a typical post order 
visitor definition should look like this:
   ```
   fn r#sturct(&self, array: &StructArray, children: Vec<Vec<Self::>>) -> 
Result<Vec<Self::T>>;
   ```
   
   And we should move this logic into a standalone function like this:
   ```
   fn visit(array: &Array, visitor: V) -> Result<V::T> {
    ...
   }



-- 
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: issues-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to