klion26 commented on code in PR #10157:
URL: https://github.com/apache/arrow-rs/pull/10157#discussion_r3656492023


##########
parquet-variant/src/variant/decimal.rs:
##########
@@ -141,6 +146,37 @@ macro_rules! impl_variant_decimal {
             pub fn scale(&self) -> u8 {
                 self.scale
             }
+
+            #[doc = concat!(
+                        "Returns Some(`",
+                        stringify!($native),
+                        "`) if scale is zero or integer of the decimal is 
divisible by 10^scale,\n",
+                        "None for other values.\n\n",
+                        "",
+                        "# Examples\n",
+                        "```rust\n",
+                        "use parquet_variant::", stringify!($struct_name), 
";\n",
+                        "//Return the integer if scale is 0\n",
+                        "let d1 = ", stringify!($struct_name), "::try_new(123, 
0).unwrap();\n",
+                        "assert_eq!(d1.as_integer(), Some(123));\n",
+                        "// or if the integer is divisible by 10^scale\n",
+                        "let d2 = ", stringify!($struct_name), "::try_new(100, 
2).unwrap();\n",
+                        "assert_eq!(d2.as_integer(), Some(1));\n",
+                        "// or if the integer is 0\n",
+                        "let d3 = ", stringify!($struct_name), "::try_new(0, 
4).unwrap();\n",
+                        "assert_eq!(d3.as_integer(), Some(0));\n",
+                        "// but not if the integer is not divisible by 
10^scale\n",
+                        "let d4 = ", stringify!($struct_name), "::try_new(123, 
2).unwrap();\n",
+                        "assert_eq!(d4.as_integer(), None);\n",
+                        "```\n",
+                    )]
+            pub fn as_integer(&self) -> Option<$native> {

Review Comment:
   1. I thought that positive is the same as the negative here, but add a 
negative number will make it more intuitive. 
   2. The doc tests of `Variant::as_x` covers this 



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