Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BufRead for JSON Schema Inference #4041

Merged
merged 1 commit into from
Apr 9, 2023

Conversation

WenyXu
Copy link
Member

@WenyXu WenyXu commented Apr 9, 2023

Which issue does this PR close?

Rationale for this change

Enhance API flexibility.

In our use case, we have a SyncIoBridge which implements the Read and BufRead traits, and it works well with arrow::csv::reader::infer_reader_schema.

        let reader = SyncIoBridge::new(decoded);

        let (schema, _records_read) = arrow::csv::reader::infer_reader_schema(
            reader,
            self.delimiter,
            self.schema_infer_max_record,
            self.has_header,
        )

However, the ValueIter::new only accepts the type of BufReader<Reader> argument. If changing BufReader<Read> to BufRead, We can call the API without the BufReader wrapped outside.

        let mut reader = BufReader::new(SyncIoBridge::new(decoded));
        let iter = ValueIter::new(&mut reader, self.schema_infer_max_record);

What changes are included in this PR?

Refactor infer_json_scheam's reader type from BufReader to BufRead

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Apr 9, 2023
@tustvold tustvold added the api-change Changes to the arrow API label Apr 9, 2023
@WenyXu WenyXu force-pushed the refactor/arrow-json-value-iter branch from 4cc7b07 to a8e152e Compare April 9, 2023 16:51
@WenyXu
Copy link
Member Author

WenyXu commented Apr 9, 2023

The Clippy seems failed with:

error: ambiguous glob re-exports
  --> arrow/src/compute/kernels/mod.rs:31:13
   |
31 |     pub use arrow_ord::comparison::*;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^ the name `contains_utf8` in the value namespace is first re-exported here
32 |     pub use arrow_string::like::*;
   |             --------------------- but the name `contains_utf8` in the value namespace is also re-exported here
   |
   = note: `-D ambiguous-glob-reexports` implied by `-D warnings`

error: could not compile `arrow` (lib) due to previous error

@viirya
Copy link
Member

viirya commented Apr 9, 2023

Where did you see the clippy error? It was not detected by CI.

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me.

@tustvold tustvold changed the title refactor: refactor from BufReader<Read> to BufRead Use BufRead for JSON Schema Inference Apr 9, 2023
@tustvold tustvold merged commit fec282f into apache:master Apr 9, 2023
@tustvold
Copy link
Contributor

tustvold commented Apr 9, 2023

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants