datafusion_common/file_options/
file_type.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//! File type abstraction
19
20use std::any::Any;
21use std::fmt::Display;
22
23/// The default file extension of arrow files
24pub const DEFAULT_ARROW_EXTENSION: &str = ".arrow";
25/// The default file extension of avro files
26pub const DEFAULT_AVRO_EXTENSION: &str = ".avro";
27/// The default file extension of csv files
28pub const DEFAULT_CSV_EXTENSION: &str = ".csv";
29/// The default file extension of json files
30pub const DEFAULT_JSON_EXTENSION: &str = ".json";
31/// The default file extension of parquet files
32pub const DEFAULT_PARQUET_EXTENSION: &str = ".parquet";
33
34/// Define each `FileType`/`FileCompressionType`'s extension
35pub trait GetExt {
36    /// File extension getter
37    fn get_ext(&self) -> String;
38}
39
40/// Defines the functionality needed for logical planning for
41/// a type of file which will be read or written to storage.
42pub trait FileType: GetExt + Display + Send + Sync {
43    /// Returns the table source as [`Any`] so that it can be
44    /// downcast to a specific implementation.
45    fn as_any(&self) -> &dyn Any;
46}