datafusion_datasource_csv/mod.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#![cfg_attr(test, allow(clippy::needless_pass_by_value))]
19// Make sure fast / cheap clones on Arc are explicit:
20// https://github.com/apache/datafusion/issues/11143
21#![cfg_attr(not(test), deny(clippy::clone_on_ref_ptr))]
22#![deny(clippy::allow_attributes)]
23
24pub mod file_format;
25pub mod source;
26
27use std::sync::Arc;
28
29use datafusion_common::Result;
30use datafusion_datasource::file_groups::FileGroup;
31use datafusion_datasource::file_scan_config::FileScanConfigBuilder;
32use datafusion_datasource::{file::FileSource, file_scan_config::FileScanConfig};
33use datafusion_execution::object_store::ObjectStoreUrl;
34pub use file_format::*;
35
36/// Returns a [`FileScanConfig`] for given `file_groups`
37pub fn partitioned_csv_config(
38 file_groups: Vec<FileGroup>,
39 file_source: Arc<dyn FileSource>,
40) -> Result<FileScanConfig> {
41 Ok(
42 FileScanConfigBuilder::new(ObjectStoreUrl::local_filesystem(), file_source)
43 .with_file_groups(file_groups)
44 .build(),
45 )
46}