databendlabs/databend · warning

expected csv params

Error message

expected csv params

What it means

In the unit-test helper get_csv_params, parsed FileFormatParams are narrowed to CsvFileFormatParams and any other variant panics with unreachable!("expected csv params"). It indicates the supplied options did not parse into the Csv variant the test requires.

Solutions

  1. Verify the options map includes the correct CSV format/TYPE value so parsing yields FileFormatParams::Csv.
  2. Make the helper panic with the actual variant for diagnosability.
  3. Fix the parser regression if these options are meant to be Csv.

Example fix

// before
match params {
    FileFormatParams::Csv(v) => v,
    _ => unreachable!("expected csv params"),
}
// after
match params {
    FileFormatParams::Csv(v) => v,
    other => panic!("expected csv params, got {:?}", other),
}
Defensive patterns

Strategy: validation

Validate before calling

let parsed = FileFormatParams::try_from_reader(FileFormatOptionsReader::from_map(options.clone()), false)
    .expect("options should parse");
assert!(matches!(parsed, FileFormatParams::Csv(_)), "options must yield Csv params: {:?}", parsed);

Prevention

When it happens

Trigger: Feeding get_csv_params an options map that parses to FileFormatParams::Text, Json, etc. — for instance a wrong TYPE value, missing format key, or modified parsing that reclassifies these options.

Common situations: Option-parsing refactors that change which variant CSV options map to; reusing another test's options map; renaming CSV format identifiers.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/de4b7f01d4b1dfac. Report an issue: GitHub.

Appendix: source

Thrown at src/meta/app/src/principal/file_format.rs:1309

    use super::*;

    fn get_text_params(options: BTreeMap<String, String>) -> TextFileFormatParams {
        let params =
            FileFormatParams::try_from_reader(FileFormatOptionsReader::from_map(options), false)
                .expect("tsv file format options should parse");
        match params {
            FileFormatParams::Text(v) => v,
            _ => unreachable!("expected tsv params"),
        }
    }

    fn get_csv_params(options: BTreeMap<String, String>) -> CsvFileFormatParams {
        let params =
            FileFormatParams::try_from_reader(FileFormatOptionsReader::from_map(options), false)
                .expect("csv file format options should parse");
        match params {
            FileFormatParams::Csv(v) => v,
            _ => unreachable!("expected csv params"),
        }
    }

    #[test]
    fn test_text_field_delimiter_empty_string() {
        let mut options = BTreeMap::new();
        options.insert("type".to_string(), "TEXT".to_string());
        options.insert("field_delimiter".to_string(), "".to_string());

        let params = get_text_params(options);
        assert_eq!(params.field_delimiter, "".to_string());
    }

    #[test]
    fn test_text_extended_options() {
        let mut options = BTreeMap::new();
        options.insert("type".to_string(), "TEXT".to_string());
        options.insert(

View on GitHub (pinned to 288d84d76e)