liukun4515 commented on code in PR #3431:
URL: https://github.com/apache/arrow-rs/pull/3431#discussion_r1065779555


##########
parquet/src/arrow/schema/mod.rs:
##########
@@ -399,21 +399,32 @@ fn arrow_to_parquet_type(field: &Field) -> Result<Type> {
                 .with_length(*length)
                 .build()
         }
-        DataType::Decimal128(precision, scale)
-        | DataType::Decimal256(precision, scale) => {
+        DataType::Decimal128(precision, scale) => {
             // Decimal precision determines the Parquet physical type to use.
-            // TODO(ARROW-12018): Enable the below after ARROW-10818 Decimal 
support
-            //
-            // let (physical_type, length) = if *precision > 1 && *precision 
<= 9 {
-            //     (PhysicalType::INT32, -1)
-            // } else if *precision <= 18 {
-            //     (PhysicalType::INT64, -1)
-            // } else {
-            //     (
-            //         PhysicalType::FIXED_LEN_BYTE_ARRAY,
-            //         decimal_length_from_precision(*precision) as i32,
-            //     )
-            // };
+            // Following the: 
https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#decimal
+            let (physical_type, length) = if *precision > 1 && *precision <= 9 
{
+                (PhysicalType::INT32, -1)
+            } else if *precision <= 18 {
+                (PhysicalType::INT64, -1)
+            } else {
+                (
+                    PhysicalType::FIXED_LEN_BYTE_ARRAY,
+                    decimal_length_from_precision(*precision) as i32,
+                )
+            };
+            Type::primitive_type_builder(name, physical_type)
+                .with_repetition(repetition)
+                .with_length(length)
+                .with_logical_type(Some(LogicalType::Decimal {
+                    scale: *scale as i32,
+                    precision: *precision as i32,
+                }))
+                .with_precision(*precision as i32)
+                .with_scale(*scale as i32)
+                .build()
+        }
+        DataType::Decimal256(precision, scale) => {

Review Comment:
   Now we ignore the decimal 256



-- 
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: [email protected]

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

Reply via email to