alamb commented on a change in pull request #779:
URL: https://github.com/apache/arrow-rs/pull/779#discussion_r763469634



##########
File path: arrow/src/array/array_primitive.rs
##########
@@ -649,6 +650,23 @@ mod tests {
         assert!(arr.is_null(1));
         assert_eq!(-5, arr.value(2));
         assert_eq!(-5, arr.values()[2]);
+
+        // a month_day_nano interval contains months, days and nanoseconds,
+        // but we do not yet have accessors for the values.
+        // TODO: implement month, day, and nanos access method for 
month_day_nano.

Review comment:
       👍  When this PR is merged, I will try and file a ticket for adding these 
accessors -- I think it would be a fairly good "first PR" type change for new 
contributors

##########
File path: integration-testing/unskip.patch
##########
@@ -0,0 +1,32 @@
+// 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.
+
+diff --git a/dev/archery/archery/integration/datagen.py 
b/dev/archery/archery/integration/datagen.py
+index 6a077a893..104c49c52 100644
+--- a/dev/archery/archery/integration/datagen.py
++++ b/dev/archery/archery/integration/datagen.py
+@@ -1579,8 +1579,7 @@ def get_generated_json_files(tempdir=None):
+
+         generate_month_day_nano_interval_case()
+         .skip_category('C#')
+-        .skip_category('JS')
+-        .skip_category('Rust'),
++        .skip_category('JS'),

Review comment:
       🎉 
   
   so is the intent that after we merge this PR into `arrow-rs` we would then 
go upstream and apply this patch in the arrow repo?

##########
File path: integration-testing/src/lib.rs
##########
@@ -280,6 +280,56 @@ fn array_from_json(
             }
             Ok(Arc::new(b.finish()))
         }
+        DataType::Interval(IntervalUnit::MonthDayNano) => {
+            let mut b = IntervalMonthDayNanoBuilder::new(json_col.count);
+            for (is_valid, value) in json_col
+                .validity
+                .as_ref()
+                .unwrap()
+                .iter()
+                .zip(json_col.data.unwrap())
+            {
+                match is_valid {
+                    1 => b.append_value(match value {
+                        Value::Object(v) => {
+                            let months = v.get("months").unwrap();
+                            let days = v.get("days").unwrap();
+                            let nanoseconds = v.get("nanoseconds").unwrap();
+                            println!(
+                                "months={:?} days={:?} nanos={:?}",
+                                months, days, nanoseconds
+                            );
+                            match (months, days, nanoseconds) {
+                                (
+                                    Value::Number(months),
+                                    Value::Number(days),
+                                    Value::Number(nanoseconds),
+                                ) => {
+                                    let months = months.as_i64().unwrap() as 
i32;
+                                    let days = days.as_i64().unwrap() as i32;
+                                    let nanoseconds = 
nanoseconds.as_i64().unwrap();
+                                    let months_days_ns: i128 = ((nanoseconds 
as i128)
+                                        & 0xFFFFFFFFFFFFFFFF)
+                                        << 64
+                                        | ((days as i128) & 0xFFFFFFFF) << 32
+                                        | ((months as i128) & 0xFFFFFFFF);
+                                    println!("months_days_ns={:?}", 
months_days_ns);
+                                    months_days_ns
+                                }
+                                (_, _, _) => {
+                                    panic!("Unable to parse {:?} as 
MonthDayNano", v)
+                                }
+                            }
+                        }
+                        _ => panic!("Unable to parse {:?} as MonthDayNano", 
value),
+                    }),
+                    _ => b.append_null(),
+                }?;
+            }
+            let array = Arc::new(b.finish()) as ArrayRef;
+            arrow::compute::cast(&array, field.data_type())

Review comment:
       I am curious why the cast is needed




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