## Coverage Report

#### Created: 2025-11-22 06:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /Users/andrewlamb/Software/datafusion/datafusion/common/src/parsers.rs

    Line
    Count
    Source
    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
    //! Interval parsing logic
    19
    20
    use std::fmt::Display;
    21
    use std::str::FromStr;
    22
    23
    use crate::DataFusionError;
    24
    25
    /// Readable file compression type
    26
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    27
    pub enum CompressionTypeVariant {
    28
        /// Gzip-ed file
    29
        GZIP,
    30
        /// Bzip2-ed file
    31
        BZIP2,
    32
        /// Xz-ed file (liblzma)
    33
        XZ,
    34
        /// Zstd-ed file,
    35
        ZSTD,
    36
        /// Uncompressed file
    37
        UNCOMPRESSED,
    38
    }
    39
    40
    impl FromStr for CompressionTypeVariant {
    41
        type Err = DataFusionError;
    42
    43
    0
        fn from_str(s: &str) -> Result<Self, Self::Err> {
    44
    0
            let s = s.to_uppercase();
    45
    0
            match s.as_str() {
    46
    0
                "GZIP" | "GZ" => Ok(Self::GZIP),
    47
    0
                "BZIP2" | "BZ2" => Ok(Self::BZIP2),
    48
    0
                "XZ" => Ok(Self::XZ),
    49
    0
                "ZST" | "ZSTD" => Ok(Self::ZSTD),
    50
    0
                "" | "UNCOMPRESSED" => Ok(Self::UNCOMPRESSED),
    51
    0
                _ => Err(DataFusionError::NotImplemented(format!(
    52
    0
                    "Unsupported file compression type {s}"
    53
    0
                ))),
    54
            }
    55
    0
        }
    56
    }
    57
    58
    impl Display for CompressionTypeVariant {
    59
    0
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    60
    0
            let str = match self {
    61
    0
                Self::GZIP => "GZIP",
    62
    0
                Self::BZIP2 => "BZIP2",
    63
    0
                Self::XZ => "XZ",
    64
    0
                Self::ZSTD => "ZSTD",
    65
    0
                Self::UNCOMPRESSED => "",
    66
            };
    67
    0
            write!(f, "{str}")
    68
    0
        }
    69
    }
    70
    71
    impl CompressionTypeVariant {
    72
    0
        pub const fn is_compressed(&self) -> bool {
    73
    0
            !matches!(self, &Self::UNCOMPRESSED)
    74
    0
        }
    75
    }