{"record":{"id":"00604cbf6dd8d5a5","repo":"quickwit-oss/quickwit","slug":"merge-requires-at-least-one-input","errorCode":null,"errorMessage":"merge requires at least one input","messagePattern":"merge requires at least one input","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-parquet-engine/src/merge/streaming.rs","lineNumber":154,"sourceCode":"}\n\n#[cfg(not(any(test, feature = \"testsuite\")))]\npub(crate) fn record_body_col_page_cache_len(_len: usize) {}\n\n/// Streaming N-input → M-output column-major merge.\n///\n/// See module docs for the four phases. Returns one\n/// [`MergeOutputFile`] per output file produced (zero-row outputs are\n/// dropped). Caller's `config.num_outputs` is the upper bound on the\n/// number of files; fewer are returned when there are not enough\n/// `sorted_series` transitions to split at.\npub async fn streaming_merge_sorted_parquet_files(\n    inputs: Vec<Box<dyn ColumnPageStream>>,\n    output_dir: &Path,\n    config: &MergeConfig,\n) -> Result<Vec<MergeOutputFile>> {\n    if inputs.is_empty() {\n        bail!(\"merge requires at least one input\");\n    }\n    if config.num_outputs == 0 {\n        bail!(\"num_outputs must be at least 1\");\n    }\n\n    let input_meta = extract_and_validate_input_metadata(&inputs)?;\n\n    // Reject legacy multi-RG inputs (`rg_partition_prefix_len == 0`\n    // AND any input has >1 row group). These have no alignment claim,\n    // so RG boundaries are arbitrary row counts that may split a\n    // single sort-key value across two RGs. The streaming engine\n    // cannot determine merge regions without column-chunk-bounded\n    // buffering; such inputs must go through `LegacyInputAdapter`\n    // (from PR-5, see `storage::legacy_adapter`), which presents\n    // them as one synthetic single-RG stream.\n    //\n    // This guard catches caller bugs — production code always routes\n    // legacy splits through the adapter (see `merge::execute_merge_operation`","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-parquet-engine/src/merge/streaming.rs#L136-L172","documentation":"streaming_merge_sorted_parquet_files requires at least one input column-page stream; an empty inputs vector cannot produce a merged file and is rejected immediately. Callers should decide themselves what an empty merge means (typically no output).","triggerScenarios":"Calling streaming_merge_sorted_parquet_files with an empty Vec<Box<dyn ColumnPageStream>> — e.g. no parquet files to merge, or all inputs filtered out before building streams.","commonSituations":"Merge tasks scheduled on an empty split set; callers opening streams lazily and skipping files that failed or were deleted, ending up with zero streams.","solutions":["Check inputs.is_empty() before calling and skip the merge (emit no output) in that case.","Fix the stream-building stage so every selected split yields exactly one stream.","If an empty merge should be an error in your workflow, surface a clearer error upstream naming the empty split set."],"exampleFix":"// before\nlet outputs = streaming_merge_sorted_parquet_files(streams, &out, &cfg).await?;\n// after\nif streams.is_empty() {\n    return Ok(Vec::new()); // nothing to merge\n}\nlet outputs = streaming_merge_sorted_parquet_files(streams, &out, &cfg).await?;","handlingStrategy":"validation","validationCode":"if streams.is_empty() { return Ok(Vec::new()); } // nothing to merge","typeGuard":null,"tryCatchPattern":"match streaming_merge_sorted_parquet_files(streams, &out, &cfg).await {\n    Err(e) if e.to_string() == \"merge requires at least one input\" => Ok(Vec::new()),\n    other => other,\n}","preventionTips":["Skip empty merge tasks at the scheduler level.","Count streams and splits before invoking the merger.","Test the pipeline with splits that decode to zero rows."],"tags":["merge","streaming","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}