eerhardt commented on a change in pull request #11931:
URL: https://github.com/apache/arrow/pull/11931#discussion_r771857374



##########
File path: csharp/src/Apache.Arrow/Arrays/FieldComparer.cs
##########
@@ -0,0 +1,61 @@
+// 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.
+
+using System.Linq;
+
+namespace Apache.Arrow
+{
+    public static class FieldComparer

Review comment:
       ```suggestion
       internal static class FieldComparer
   ```

##########
File path: csharp/src/Apache.Arrow/Arrays/ArrayDataTypeComparer.cs
##########
@@ -0,0 +1,155 @@
+// 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.
+
+using System;
+using Apache.Arrow.Types;
+
+namespace Apache.Arrow
+{
+    public class ArrayDataTypeComparer :
+        IArrowTypeVisitor<TimestampType>,
+        IArrowTypeVisitor<Date32Type>,
+        IArrowTypeVisitor<Date64Type>,
+        IArrowTypeVisitor<Time32Type>,
+        IArrowTypeVisitor<Time64Type>,
+        IArrowTypeVisitor<FixedSizeBinaryType>,
+        IArrowTypeVisitor<ListType>,
+        IArrowTypeVisitor<StructType>
+    {
+        private readonly IArrowType _expectedType;
+        private bool _dataTypeMatch;
+
+        public ArrayDataTypeComparer(IArrowType expectedType)
+        {
+            _expectedType = expectedType;
+            _dataTypeMatch = false;

Review comment:
       ```suggestion
   ```
   
   This is not needed. `bool` fields default to `false`.

##########
File path: csharp/src/Apache.Arrow/Arrays/ArrayDataTypeComparer.cs
##########
@@ -0,0 +1,161 @@
+// 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.
+
+using System.Diagnostics;
+using Apache.Arrow.Types;
+
+namespace Apache.Arrow
+{
+    public class ArrayTypeComparer :

Review comment:
       ```suggestion
       internal sealed class ArrayTypeComparer :
   ```
   
   I don't believe this class needs to be public.

##########
File path: csharp/src/Apache.Arrow/Column.cs
##########
@@ -60,9 +60,19 @@ public Column Slice(int offset)
 
         private bool ValidateArrayDataTypes()
         {
+

Review comment:
       ```suggestion
   ```
   
   This blank line is unnecessary.

##########
File path: csharp/src/Apache.Arrow/Arrays/ArrayDataTypeComparer.cs
##########
@@ -0,0 +1,155 @@
+// 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.
+
+using System;
+using Apache.Arrow.Types;
+
+namespace Apache.Arrow
+{
+    public class ArrayDataTypeComparer :
+        IArrowTypeVisitor<TimestampType>,
+        IArrowTypeVisitor<Date32Type>,
+        IArrowTypeVisitor<Date64Type>,
+        IArrowTypeVisitor<Time32Type>,
+        IArrowTypeVisitor<Time64Type>,
+        IArrowTypeVisitor<FixedSizeBinaryType>,
+        IArrowTypeVisitor<ListType>,
+        IArrowTypeVisitor<StructType>
+    {
+        private readonly IArrowType _expectedType;
+        private bool _dataTypeMatch;
+
+        public ArrayDataTypeComparer(IArrowType expectedType)
+        {
+            _expectedType = expectedType;
+            _dataTypeMatch = false;
+        }
+
+        public bool DataTypeMatch => _dataTypeMatch;
+
+        public void Visit(TimestampType actualType)
+        {
+            var expectedType = (TimestampType)_expectedType;

Review comment:
       What happens if `_expectedType` isn't a `TimestampType`? This will throw 
an InvalidCastException, which I don't believe is the behavior we want. 
Instead, this should use `as` or `is`, and return `false` if the types don't 
match.




-- 
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-unsubscr...@arrow.apache.org

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


Reply via email to