tustvold commented on code in PR #4773:
URL: https://github.com/apache/arrow-rs/pull/4773#discussion_r1328711317


##########
parquet_derive/src/parquet_field.rs:
##########
@@ -354,6 +428,50 @@ impl Field {
         }
     }
 
+    fn copied_direct_fields(&self) -> proc_macro2::TokenStream {
+        let field_name = &self.ident;
+        let is_a_byte_buf = self.is_a_byte_buf;
+        let is_a_timestamp =
+            self.third_party_type == Some(ThirdPartyType::ChronoNaiveDateTime);
+        let is_a_date = self.third_party_type == 
Some(ThirdPartyType::ChronoNaiveDate);
+        let is_a_uuid = self.third_party_type == Some(ThirdPartyType::Uuid);
+
+        let value = if is_a_timestamp {
+            quote! { 
::chrono::naive::NaiveDateTime::from_timestamp_millis(vals[i]).unwrap() }
+        } else if is_a_date {
+            quote! { 
::chrono::naive::NaiveDate::from_num_days_from_ce_opt(vals[i]
+            + ((::chrono::naive::NaiveDate::from_ymd_opt(1970, 1, 1).unwrap()
+            - ::chrono::naive::NaiveDate::from_ymd_opt(0, 12, 
31).unwrap()).num_days()) as i32).unwrap() }
+        } else if is_a_uuid {
+            quote! { 
::uuid::Uuid::parse_str(vals[i].data().convert()).unwrap() }
+        } else if is_a_byte_buf {
+            quote! { vals[i].data().convert() }
+        } else {
+            quote! { vals[i].convert() }
+        };
+
+        // The below code would support references in field types, but it 
prevents the compiler

Review Comment:
   If you have a reference such as `&'a str` wrapping it up in a allocation, 
e.g. `Rc<&'a str>` doesn't remove the lifetime, just adds an indirection. To 
remove the lifetime you would need to create a `Rc<str>` which will perform a 
new allocation and clone the string data. In this case using `String` would be 
equivalent



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