You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/01/22 12:39:56 UTC

[GitHub] [arrow] alamb commented on a change in pull request #9232: ARROW-10818: [Rust] Implement DecimalType

alamb commented on a change in pull request #9232:
URL: https://github.com/apache/arrow/pull/9232#discussion_r562604038



##########
File path: rust/arrow/src/datatypes/mod.rs
##########
@@ -199,6 +207,81 @@ pub struct Field {
     metadata: Option<BTreeMap<String, String>>,
 }
 
+// Decimal (precision, scale) = Decimal(1, 2) = 1.00
+pub trait ArrowDecimalType: fmt::Debug + Send + Sync + FromStr + PartialEq {
+    const MAX_DIGITS: usize;
+
+    // fn into_json_value(self) -> Option<Value>;
+
+    fn get_byte_width_for_precision_scale(precision: usize, scale: usize) -> usize;
+
+    // Rescale scale part
+    fn rescale(&mut self, scale: usize);
+
+    // Try to parse string with precision, scale
+    fn parse(
+        string: &str,
+        precision: usize,
+        scale: usize,
+    ) -> std::result::Result<Self, ParseDecimalError>;
+
+    fn to_byte_slice(&self) -> Vec<u8>;
+
+    fn from_bytes_with_precision_scale(
+        bytes: &[u8],
+        precision: usize,
+        scale: usize,
+    ) -> Self;
+}
+
+#[derive(Debug)]
+pub enum DecimalType {

Review comment:
       Hi @ovr  -- sorry for the lack of response. I am not familiar with this code so I will need some non trivial time to review and think about your question. I hope to find some time this weekend to do so. 




----------------------------------------------------------------
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:
users@infra.apache.org