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



##########
File path: csharp/src/Apache.Arrow/Arrays/DecimalArray.cs
##########
@@ -0,0 +1,45 @@
+// 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 Apache.Arrow.Types;
+
+namespace Apache.Arrow
+{
+    public class DecimalArray : PrimitiveArray<decimal>

Review comment:
       I don't think the C# in-memory format of decimal is the same layout as 
the Arrow decimal format, is it? I'm trying to find the documentation on the 
memory layout, the only thing I can find is in the Schema.fbs:
   
   
https://github.com/apache/arrow/blob/e676aeacb2c6597c063faeed20d6142b0df938d8/format/Schema.fbs#L176-L185
   
   The C# decimal layout is different:
   
   
https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=net-5.0#remarks
   
   > The binary representation of a Decimal value consists of a 1-bit sign, a 
96-bit integer number, and a scaling factor used to divide the 96-bit integer 
and specify what portion of it is a decimal fraction. The scaling factor is 
implicitly the number 10, raised to an exponent ranging from 0 to 28.

##########
File path: csharp/src/Apache.Arrow/Types/DecimalType.cs
##########
@@ -17,6 +17,7 @@ namespace Apache.Arrow.Types
 {
     public sealed class DecimalType: FixedSizeBinaryType
     {
+        public static readonly DecimalType Default = new DecimalType(0, 0);

Review comment:
       I'm not sure a decimal with precision = 0 is valid.
   
   Looking at the C++ implementation, I don't see a "default" DecimalType being 
defined. Maybe it is best to leave it up to the caller?

##########
File path: csharp/src/Apache.Arrow/Arrays/DecimalArray.cs
##########
@@ -0,0 +1,45 @@
+// 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 Apache.Arrow.Types;
+
+namespace Apache.Arrow
+{
+    public class DecimalArray : PrimitiveArray<decimal>

Review comment:
       Thanks @emkornfield. One thing that I don't quite understand is the 
`precision` field in metadata. The data is fixed sized right? So each value 
will always take up 128 or 256 bits. But if I set the precision lower than `38` 
for a Decimal128, what exactly does that mean? Does it mean to ignore digits at 
the beginning of the integer? For example:
   
   ```
   Precision = 3
   Scale = 0
   Data Value = 0b010111011100   (1,500 in binary)
   ```
   
   I assume this number means `500`, and the leading `1,000` gets truncated.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to