Skip to content

Commit 4ec8399

Browse files
committed
Merge branch 'alamb/less_cfg3' into extend-ci
2 parents b47e687 + e8674a5 commit 4ec8399

18 files changed

Lines changed: 211 additions & 78 deletions

File tree

datafusion/common/src/file_options/file_type.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub enum FileType {
4848
/// Apache Avro file
4949
AVRO,
5050
/// Apache Parquet file
51-
#[cfg(feature = "parquet")]
5251
PARQUET,
5352
/// CSV file
5453
CSV,
@@ -61,7 +60,6 @@ impl GetExt for FileType {
6160
match self {
6261
FileType::ARROW => DEFAULT_ARROW_EXTENSION.to_owned(),
6362
FileType::AVRO => DEFAULT_AVRO_EXTENSION.to_owned(),
64-
#[cfg(feature = "parquet")]
6563
FileType::PARQUET => DEFAULT_PARQUET_EXTENSION.to_owned(),
6664
FileType::CSV => DEFAULT_CSV_EXTENSION.to_owned(),
6765
FileType::JSON => DEFAULT_JSON_EXTENSION.to_owned(),
@@ -74,7 +72,6 @@ impl Display for FileType {
7472
let out = match self {
7573
FileType::CSV => "csv",
7674
FileType::JSON => "json",
77-
#[cfg(feature = "parquet")]
7875
FileType::PARQUET => "parquet",
7976
FileType::AVRO => "avro",
8077
FileType::ARROW => "arrow",
@@ -91,7 +88,6 @@ impl FromStr for FileType {
9188
match s.as_str() {
9289
"ARROW" => Ok(FileType::ARROW),
9390
"AVRO" => Ok(FileType::AVRO),
94-
#[cfg(feature = "parquet")]
9591
"PARQUET" => Ok(FileType::PARQUET),
9692
"CSV" => Ok(FileType::CSV),
9793
"JSON" | "NDJSON" => Ok(FileType::JSON),

datafusion/common/src/file_options/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub mod avro_writer;
2222
pub mod csv_writer;
2323
pub mod file_type;
2424
pub mod json_writer;
25-
#[cfg(feature = "parquet")]
2625
pub mod parquet_writer;
2726
pub(crate) mod parse_utils;
2827

@@ -38,14 +37,13 @@ use crate::{
3837
DataFusionError, FileType, Result,
3938
};
4039

41-
#[cfg(feature = "parquet")]
42-
use self::parquet_writer::ParquetWriterOptions;
43-
4440
use self::{
4541
arrow_writer::ArrowWriterOptions, avro_writer::AvroWriterOptions,
4642
csv_writer::CsvWriterOptions, json_writer::JsonWriterOptions,
4743
};
4844

45+
use self::parquet_writer::ParquetWriterOptions;
46+
4947
/// Represents a single arbitrary setting in a
5048
/// [StatementOptions] where OptionTuple.0 determines
5149
/// the specific setting to be modified and OptionTuple.1
@@ -148,7 +146,6 @@ impl StatementOptions {
148146
/// plus any DataFusion specific writing options (e.g. CSV compression)
149147
#[derive(Clone, Debug)]
150148
pub enum FileTypeWriterOptions {
151-
#[cfg(feature = "parquet")]
152149
Parquet(ParquetWriterOptions),
153150
CSV(CsvWriterOptions),
154151
JSON(JsonWriterOptions),
@@ -168,7 +165,6 @@ impl FileTypeWriterOptions {
168165
let options = (config_defaults, statement_options);
169166

170167
let file_type_write_options = match file_type {
171-
#[cfg(feature = "parquet")]
172168
FileType::PARQUET => {
173169
FileTypeWriterOptions::Parquet(ParquetWriterOptions::try_from(options)?)
174170
}
@@ -198,7 +194,6 @@ impl FileTypeWriterOptions {
198194
let options = (config_defaults, &empty_statement);
199195

200196
let file_type_write_options = match file_type {
201-
#[cfg(feature = "parquet")]
202197
FileType::PARQUET => {
203198
FileTypeWriterOptions::Parquet(ParquetWriterOptions::try_from(options)?)
204199
}
@@ -221,7 +216,6 @@ impl FileTypeWriterOptions {
221216

222217
/// Tries to extract ParquetWriterOptions from this FileTypeWriterOptions enum.
223218
/// Returns an error if a different type from parquet is set.
224-
#[cfg(feature = "parquet")]
225219
pub fn try_into_parquet(&self) -> Result<&ParquetWriterOptions> {
226220
match self {
227221
FileTypeWriterOptions::Parquet(opt) => Ok(opt),
@@ -288,7 +282,6 @@ impl Display for FileTypeWriterOptions {
288282
FileTypeWriterOptions::Avro(_) => "AvroWriterOptions",
289283
FileTypeWriterOptions::CSV(_) => "CsvWriterOptions",
290284
FileTypeWriterOptions::JSON(_) => "JsonWriterOptions",
291-
#[cfg(feature = "parquet")]
292285
FileTypeWriterOptions::Parquet(_) => "ParquetWriterOptions",
293286
};
294287
write!(f, "{}", name)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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(feature = "parquet")]
19+
mod parquet;
20+
21+
#[cfg(feature = "parquet")]
22+
pub use self::parquet::*;
23+
24+
#[cfg(not(feature = "parquet"))]
25+
mod parquet_stub;
26+
27+
#[cfg(not(feature = "parquet"))]
28+
pub use parquet_stub::*;

datafusion/common/src/file_options/parquet_writer.rs renamed to datafusion/common/src/file_options/parquet_writer/parquet.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ use parquet::file::properties::{WriterProperties, WriterPropertiesBuilder};
2121

2222
use crate::{config::ConfigOptions, DataFusionError, Result};
2323

24-
use super::StatementOptions;
25-
24+
use crate::file_options::StatementOptions;
2625
use parquet::{
2726
basic::{BrotliLevel, GzipLevel, ZstdLevel},
2827
file::properties::{EnabledStatistics, WriterVersion},
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
use crate::config::ConfigOptions;
19+
use crate::error::_not_impl_err;
20+
use crate::file_options::StatementOptions;
21+
use crate::{DataFusionError, Result};
22+
23+
/// Stub implementation of `ParquetWriterOptions` that always returns a
24+
/// NotYetImplemented error used when parquet feature is not activated.
25+
#[derive(Clone, Debug)]
26+
pub struct ParquetWriterOptions {}
27+
28+
impl TryFrom<(&ConfigOptions, &StatementOptions)> for ParquetWriterOptions {
29+
type Error = DataFusionError;
30+
31+
fn try_from(_: (&ConfigOptions, &StatementOptions)) -> Result<Self> {
32+
_not_impl_err!(
33+
"Parquet support is not enabled. Hint enable the `parquet` feature flag"
34+
)
35+
}
36+
}

datafusion/common/src/test_util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ pub fn arrow_test_data() -> String {
180180
/// let filename = format!("{}/binary.parquet", testdata);
181181
/// assert!(std::path::PathBuf::from(filename).exists());
182182
/// ```
183-
#[cfg(feature = "parquet")]
184183
pub fn parquet_test_data() -> String {
185184
match get_data_dir("PARQUET_TEST_DATA", "../../parquet-testing/data") {
186185
Ok(pb) => pb.display().to_string(),

datafusion/core/src/datasource/file_format/file_compression_type.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ impl FileTypeExt for FileType {
243243
"FileCompressionType can be specified for CSV/JSON FileType.".into(),
244244
)),
245245
},
246-
#[cfg(feature = "parquet")]
247246
FileType::PARQUET => match c.variant {
248247
UNCOMPRESSED => Ok(ext),
249248
_ => Err(DataFusionError::Internal(
@@ -285,7 +284,6 @@ mod tests {
285284

286285
let mut ty_ext_tuple = vec![];
287286
ty_ext_tuple.push((FileType::AVRO, ".avro"));
288-
#[cfg(feature = "parquet")]
289287
ty_ext_tuple.push((FileType::PARQUET, ".parquet"));
290288

291289
// Cannot specify compression for these file types

datafusion/core/src/datasource/file_format/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub mod csv;
2727
pub mod file_compression_type;
2828
pub mod json;
2929
pub mod options;
30-
#[cfg(feature = "parquet")]
3130
pub mod parquet;
31+
3232
pub mod write;
3333

3434
use std::any::Any;

datafusion/core/src/datasource/file_format/options.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use datafusion_common::{plan_err, DataFusionError};
2525

2626
use crate::datasource::file_format::arrow::ArrowFormat;
2727
use crate::datasource::file_format::file_compression_type::FileCompressionType;
28-
#[cfg(feature = "parquet")]
2928
use crate::datasource::file_format::parquet::ParquetFormat;
3029
use crate::datasource::file_format::DEFAULT_SCHEMA_INFER_MAX_RECORD;
3130
use crate::datasource::listing::{ListingTableInsertMode, ListingTableUrl};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
//! FileFormat for parquet
19+
20+
/// If parquet is enabled, use actual implementation
21+
#[cfg(feature = "parquet")]
22+
mod parquet_impl;
23+
#[cfg(feature = "parquet")]
24+
pub use parquet_impl::*;
25+
26+
/// If parquet is not enabled, use dummy implementation
27+
#[cfg(not(feature = "parquet"))]
28+
mod parquet_stub;
29+
#[cfg(not(feature = "parquet"))]
30+
pub use parquet_stub::ParquetFormat;

0 commit comments

Comments
 (0)