corasaurus-hex commented on code in PR #18457:
URL: https://github.com/apache/datafusion/pull/18457#discussion_r2511160906
##########
datafusion/datasource-arrow/src/file_format.rs:
##########
@@ -151,12 +153,18 @@ impl FileFormat for ArrowFormat {
let schema = match r.payload {
#[cfg(not(target_arch = "wasm32"))]
GetResultPayload::File(mut file, _) => {
- let reader = FileReader::try_new(&mut file, None)?;
- reader.schema()
- }
- GetResultPayload::Stream(stream) => {
- infer_schema_from_file_stream(stream).await?
+ match FileReader::try_new(&mut file, None) {
+ Ok(reader) => reader.schema(),
+ Err(_) => {
+ // not in the file format, but FileReader read
some bytes
+ // while trying to parse the file and so we need
to rewind
+ // it to the beginning of the file
+ file.seek(SeekFrom::Start(0))?;
+ StreamReader::try_new(&mut file, None)?.schema()
Review Comment:
They're now combined
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]