You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "crepererum (via GitHub)" <gi...@apache.org> on 2023/04/26 09:16:12 UTC

[GitHub] [arrow-rs] crepererum commented on a diff in pull request #4133: Cleanup CSV schema inference (#4129) (#4130)

crepererum commented on code in PR #4133:
URL: https://github.com/apache/arrow-rs/pull/4133#discussion_r1177584369


##########
arrow-csv/src/reader/mod.rs:
##########
@@ -194,32 +194,150 @@ impl InferredDataType {
     }
 
     /// Updates the [`InferredDataType`] with the given string
-    fn update(&mut self, string: &str, datetime_re: Option<&Regex>) {
+    fn update(&mut self, string: &str) {
         self.packed |= if string.starts_with('"') {
             1 << 8 // Utf8
         } else if let Some(m) = REGEX_SET.matches(string).into_iter().next() {
             1 << m
         } else {
-            match datetime_re {
-                // Timestamp(Nanosecond)
-                Some(d) if d.is_match(string) => 1 << 7,
-                _ => 1 << 8, // Utf8
-            }
+            1 << 8 // Utf8

Review Comment:
   is this branch actually covered by some test?



##########
arrow-csv/src/reader/mod.rs:
##########
@@ -194,32 +194,150 @@ impl InferredDataType {
     }
 
     /// Updates the [`InferredDataType`] with the given string
-    fn update(&mut self, string: &str, datetime_re: Option<&Regex>) {
+    fn update(&mut self, string: &str) {
         self.packed |= if string.starts_with('"') {
             1 << 8 // Utf8
         } else if let Some(m) = REGEX_SET.matches(string).into_iter().next() {
             1 << m
         } else {
-            match datetime_re {
-                // Timestamp(Nanosecond)
-                Some(d) if d.is_match(string) => 1 << 7,
-                _ => 1 << 8, // Utf8
-            }
+            1 << 8 // Utf8

Review Comment:
   I think this would be way more readable using the bitflags crate (which btw. is already used by the FFI adapters) instead of some hand-rolled constants.



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org