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 2022/11/28 10:45:56 UTC

[GitHub] [arrow-rs] Jefffrey opened a new pull request, #3209: Infer timestamps from CSV files

Jefffrey opened a new pull request, #3209:
URL: https://github.com/apache/arrow-rs/pull/3209

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #1060
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   Like Pyarrow, be able to infer timestamps from CSV files (with a bit more flexibility in the default format that is used for inferring from values)
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


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


[GitHub] [arrow-rs] Jefffrey commented on a diff in pull request #3209: Infer timestamps from CSV files

Posted by GitBox <gi...@apache.org>.
Jefffrey commented on code in PR #3209:
URL: https://github.com/apache/arrow-rs/pull/3209#discussion_r1033981345


##########
arrow-csv/src/reader.rs:
##########
@@ -90,10 +92,12 @@ fn infer_field_schema(string: &str, datetime_re: Option<Regex>) -> DataType {
         DataType::Float64
     } else if INTEGER_RE.is_match(string) {
         DataType::Int64
-    } else if datetime_re.is_match(string) {
-        DataType::Date64
-    } else if DATE_RE.is_match(string) {
+    } else if DATE32_RE.is_match(string) {

Review Comment:
   Ah didn't know about RegexSet, I can give it a shot in this PR a bit later



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


[GitHub] [arrow-rs] tustvold merged pull request #3209: Infer timestamps from CSV files

Posted by GitBox <gi...@apache.org>.
tustvold merged PR #3209:
URL: https://github.com/apache/arrow-rs/pull/3209


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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3209: Infer timestamps from CSV files

Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #3209:
URL: https://github.com/apache/arrow-rs/pull/3209#discussion_r1033541345


##########
arrow-csv/src/reader.rs:
##########
@@ -70,9 +70,11 @@ lazy_static! {
         .case_insensitive(true)
         .build()
         .unwrap();
-    static ref DATE_RE: Regex = Regex::new(r"^\d{4}-\d\d-\d\d$").unwrap();
+    static ref DATE32_RE: Regex = Regex::new(r"^\d{4}-\d\d-\d\d$").unwrap();
+    static ref DATE64_RE: Regex =
+        Regex::new(r"^\d{4}-\d\d-\d\d(T|\s)\d\d:\d\d:\d\d$").unwrap();
     static ref DATETIME_RE: Regex =
-        Regex::new(r"^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d$").unwrap();
+        Regex::new(r"^\d{4}-\d\d-\d\d(T|\s)\d\d:\d\d:\d\d(.\d{1,9})?$").unwrap();

Review Comment:
   ```suggestion
           Regex::new(r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d(.\d{1,9})?$").unwrap();
   ```
   
   Or at the very least a non-capturing group. I also think it should probably be ` ` instead of `\s` as things like `\n` or `\t` I don't think would parse correctly.



##########
arrow-csv/src/reader.rs:
##########
@@ -90,10 +92,12 @@ fn infer_field_schema(string: &str, datetime_re: Option<Regex>) -> DataType {
         DataType::Float64
     } else if INTEGER_RE.is_match(string) {
         DataType::Int64
-    } else if datetime_re.is_match(string) {
-        DataType::Date64
-    } else if DATE_RE.is_match(string) {
+    } else if DATE32_RE.is_match(string) {

Review Comment:
   FWIW I created #3211 to track using a RegexSet here, as the current code is rather wasteful, perhaps something for a follow on PR?



##########
arrow-csv/src/reader.rs:
##########
@@ -70,9 +70,11 @@ lazy_static! {
         .case_insensitive(true)
         .build()
         .unwrap();
-    static ref DATE_RE: Regex = Regex::new(r"^\d{4}-\d\d-\d\d$").unwrap();
+    static ref DATE32_RE: Regex = Regex::new(r"^\d{4}-\d\d-\d\d$").unwrap();
+    static ref DATE64_RE: Regex =
+        Regex::new(r"^\d{4}-\d\d-\d\d(T|\s)\d\d:\d\d:\d\d$").unwrap();

Review Comment:
   ```suggestion
           Regex::new(r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d$").unwrap();
   ```



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


[GitHub] [arrow-rs] ursabot commented on pull request #3209: Infer timestamps from CSV files

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #3209:
URL: https://github.com/apache/arrow-rs/pull/3209#issuecomment-1329781444

   Benchmark runs are scheduled for baseline = 5d84746cfdfe3ae9a2678f10b4dbb2e9385dc479 and contender = 64b466e7864f8b019d3396c45efec81342b46a7f. 64b466e7864f8b019d3396c45efec81342b46a7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/15004d5b525a43008bb61bafa1981c58...41674932f54c4736ae20be5ce3f8787a/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/02f9b1a9151a4043b04b44e9823de3f4...ae6918be3d7849108e8d71b8eb2ab84d/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/4c220577950448d98d8aa80b189618cb...c6f5daef54e149c4bae8945586f2f6c3/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/36885bfe31fd43beb0a98956236214b2...2d73770be458412eb36171b0eec0559d/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


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


[GitHub] [arrow-rs] Jefffrey commented on a diff in pull request #3209: Infer timestamps from CSV files

Posted by GitBox <gi...@apache.org>.
Jefffrey commented on code in PR #3209:
URL: https://github.com/apache/arrow-rs/pull/3209#discussion_r1033981345


##########
arrow-csv/src/reader.rs:
##########
@@ -90,10 +92,12 @@ fn infer_field_schema(string: &str, datetime_re: Option<Regex>) -> DataType {
         DataType::Float64
     } else if INTEGER_RE.is_match(string) {
         DataType::Int64
-    } else if datetime_re.is_match(string) {
-        DataType::Date64
-    } else if DATE_RE.is_match(string) {
+    } else if DATE32_RE.is_match(string) {

Review Comment:
   Ah didn't know about RegexSet, I can give it a shot in this PR a bit later
   
   Edit: scratch that, might as well tackle as a separate PR instead



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