rdettai commented on a change in pull request #1010: URL: https://github.com/apache/arrow-datafusion/pull/1010#discussion_r714593305
########## File path: datafusion/src/datasource/file_format/mod.rs ########## @@ -0,0 +1,192 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Module containing helper methods for the various file formats + +pub mod avro; +pub mod csv; +pub mod json; +pub mod parquet; + +use std::pin::Pin; +use std::sync::Arc; + +use crate::arrow::datatypes::SchemaRef; +use crate::datasource::{create_max_min_accs, get_col_stats}; +use crate::error::Result; +use crate::logical_plan::Expr; +use crate::physical_plan::{Accumulator, ExecutionPlan, Statistics}; + +use async_trait::async_trait; +use futures::Stream; + +/// A stream of String that can be used accross await calls +pub type StringStream = Pin<Box<dyn Stream<Item = String> + Send + Sync>>; + +/// Convert a vector into a stream +pub fn string_stream(strings: Vec<String>) -> StringStream { + Box::pin(futures::stream::iter(strings)) +} + +/// This trait abstracts all the file format specific implementations +/// from the `TableProvider`. This helps code re-utilization accross +/// providers that support the the same file formats. +#[async_trait] +pub trait FileFormat: Send + Sync { + /// Open the files at the paths provided by iterator and infer the + /// common schema + async fn infer_schema(&self, paths: StringStream) -> Result<SchemaRef>; Review comment: yes, I think it will get to that while I add the `ObjectStore` abstraction -- 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]
