Skip to content

Commit

Permalink
Fix test feature selection so all feature combinations work as expect…
Browse files Browse the repository at this point in the history
…ed (#6626)

* Fix test feature selection so all feature combinations work as expected

* Consolidate cfg
  • Loading branch information
itsjunetime authored Oct 29, 2024
1 parent 122a5f4 commit 9f889aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
17 changes: 8 additions & 9 deletions parquet/src/file/metadata/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::schema::types;
use crate::schema::types::SchemaDescriptor;
use crate::thrift::{TCompactSliceInputProtocol, TSerializable};

#[cfg(feature = "async")]
#[cfg(all(feature = "async", feature = "arrow"))]
use crate::arrow::async_reader::MetadataFetch;

/// Reads the [`ParquetMetaData`] from a byte stream.
Expand Down Expand Up @@ -321,7 +321,7 @@ impl ParquetMetaDataReader {
///
/// See [`Self::with_prefetch_hint`] for a discussion of how to reduce the number of fetches
/// performed by this function.
#[cfg(feature = "async")]
#[cfg(all(feature = "async", feature = "arrow"))]
pub async fn load_and_finish<F: MetadataFetch>(
mut self,
fetch: F,
Expand All @@ -336,7 +336,7 @@ impl ParquetMetaDataReader {
///
/// See [`Self::with_prefetch_hint`] for a discussion of how to reduce the number of fetches
/// performed by this function.
#[cfg(feature = "async")]
#[cfg(all(feature = "async", feature = "arrow"))]
pub async fn try_load<F: MetadataFetch>(
&mut self,
mut fetch: F,
Expand All @@ -357,12 +357,12 @@ impl ParquetMetaDataReader {

/// Asynchronously fetch the page index structures when a [`ParquetMetaData`] has already
/// been obtained. See [`Self::new_with_metadata()`].
#[cfg(feature = "async")]
#[cfg(all(feature = "async", feature = "arrow"))]
pub async fn load_page_index<F: MetadataFetch>(&mut self, fetch: F) -> Result<()> {
self.load_page_index_with_remainder(fetch, None).await
}

#[cfg(feature = "async")]
#[cfg(all(feature = "async", feature = "arrow"))]
async fn load_page_index_with_remainder<F: MetadataFetch>(
&mut self,
mut fetch: F,
Expand Down Expand Up @@ -513,7 +513,7 @@ impl ParquetMetaDataReader {
/// Return the number of bytes to read in the initial pass. If `prefetch_size` has
/// been provided, then return that value if it is larger than the size of the Parquet
/// file footer (8 bytes). Otherwise returns `8`.
#[cfg(feature = "async")]
#[cfg(all(feature = "async", feature = "arrow"))]
fn get_prefetch_size(&self) -> usize {
if let Some(prefetch) = self.prefetch_hint {
if prefetch > FOOTER_SIZE {
Expand All @@ -523,7 +523,7 @@ impl ParquetMetaDataReader {
FOOTER_SIZE
}

#[cfg(feature = "async")]
#[cfg(all(feature = "async", feature = "arrow"))]
async fn load_metadata<F: MetadataFetch>(
fetch: &mut F,
file_size: usize,
Expand Down Expand Up @@ -851,8 +851,7 @@ mod tests {
}
}

#[cfg(feature = "async")]
#[cfg(test)]
#[cfg(all(feature = "async", feature = "arrow", test))]
mod async_tests {
use super::*;
use bytes::Bytes;
Expand Down
1 change: 1 addition & 0 deletions parquet/tests/arrow_reader/bad_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fn test_arrow_rs_gh_6229_dict_header() {
}

#[test]
#[cfg(feature = "snap")]
fn test_arrow_rs_gh_6229_dict_levels() {
let err = read_file("ARROW-RS-GH-6229-LEVELS.parquet").unwrap_err();
assert_eq!(
Expand Down
6 changes: 4 additions & 2 deletions parquet/tests/arrow_reader/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use parquet::arrow::arrow_reader::ArrowReaderBuilder;
fn test_datapage_v1_corrupt_checksum() {
let errors = read_file_batch_errors("datapage_v1-corrupt-checksum.parquet");
assert_eq!(errors, [
Err("Parquet argument error: Parquet error: Page CRC checksum mismatch".to_string()),
Err("Parquet argument error: Parquet error: Page CRC checksum mismatch".to_string()),
Ok(()),
Ok(()),
Err("Parquet argument error: Parquet error: Page CRC checksum mismatch".to_string()),
Err("Parquet argument error: Parquet error: Page CRC checksum mismatch".to_string()),
Err("Parquet argument error: Parquet error: Not all children array length are the same!".to_string())
]);
}
Expand All @@ -41,6 +41,7 @@ fn test_datapage_v1_uncompressed_checksum() {
}

#[test]
#[cfg(feature = "snap")]
fn test_datapage_v1_snappy_compressed_checksum() {
let errors = read_file_batch_errors("datapage_v1-snappy-compressed-checksum.parquet");
assert_eq!(errors, [Ok(()), Ok(()), Ok(()), Ok(()), Ok(())]);
Expand All @@ -52,6 +53,7 @@ fn test_plain_dict_uncompressed_checksum() {
assert_eq!(errors, [Ok(())]);
}
#[test]
#[cfg(feature = "snap")]
fn test_rle_dict_snappy_checksum() {
let errors = read_file_batch_errors("rle-dict-snappy-checksum.parquet");
assert_eq!(errors, [Ok(())]);
Expand Down

0 comments on commit 9f889aa

Please sign in to comment.