sunchao commented on a change in pull request #9047:
URL: https://github.com/apache/arrow/pull/9047#discussion_r550321322



##########
File path: rust/parquet/src/arrow/schema.rs
##########
@@ -657,6 +645,22 @@ impl ParquetTypeConverter<'_> {
         }
     }
 
+    fn to_decimal(&self) -> Result<DataType> {
+        let (precision, scale) = match self.schema {
+            Type::PrimitiveType {
+                ref precision,
+                ref scale,
+                ..
+            } => (*precision, *scale),
+            _ => {
+                return Err(ArrowError(

Review comment:
       I think you can use assertion here since this is only supposed to be 
called on primitive types. And it's more concise to do something like this:
   
   ```rust
           match self.schema {
               Type::PrimitiveType {
                   ref precision,
                   ref scale,
                   ..
               } => Ok(DataType::Decimal(*precision as usize, *scale as usize)),
               _ => Err(ArrowError(
                   "Expected a physical type, not a group type".to_string(),
               )),
           }
   ```

##########
File path: rust/arrow/src/compute/kernels/cast.rs
##########
@@ -532,6 +533,7 @@ pub fn cast(array: &ArrayRef, to_type: &DataType) -> 
Result<ArrayRef> {
         (Int64, Int32) => cast_numeric_arrays::<Int64Type, Int32Type>(array),
         (Int64, Float32) => cast_numeric_arrays::<Int64Type, 
Float32Type>(array),
         (Int64, Float64) => cast_numeric_arrays::<Int64Type, 
Float64Type>(array),
+        (Int64, Decimal(p, s)) => int64_to_decimal_cast(array, *p, *s),

Review comment:
       hmm... is this related to the parquet-side change?

##########
File path: rust/parquet/src/arrow/schema.rs
##########
@@ -591,6 +591,7 @@ impl ParquetTypeConverter<'_> {
             LogicalType::INT_32 => Ok(DataType::Int32),
             LogicalType::DATE => Ok(DataType::Date32(DateUnit::Day)),
             LogicalType::TIME_MILLIS => 
Ok(DataType::Time32(TimeUnit::Millisecond)),
+            LogicalType::DECIMAL => self.to_decimal(),

Review comment:
       should this be handled somehow in the parquet/arrow reader? 




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