{"record":{"id":"f670fbac94c3e5a9","repo":"pola-rs/polars","slug":"we-should-have-num-rows-when-we-are-writing-f670fb","errorCode":null,"errorMessage":"We should have num_rows when we are writing","messagePattern":"We should have num_rows when we are writing","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-parquet/src/parquet/write/page.rs","lineNumber":63,"sourceCode":"    pub num_values: usize,\n    /// The number of actual rows. For non-nested values, this is equal to the number of values.\n    pub num_rows: usize,\n    pub header_size: u64,\n    pub offset: u64,\n    pub bytes_written: u64,\n    pub compression: Compression,\n    pub statistics: Option<Statistics>,\n}\n\npub fn write_page<W: Write>(\n    writer: &mut W,\n    offset: u64,\n    compressed_page: &CompressedPage,\n) -> ParquetResult<PageWriteSpec> {\n    let num_values = compressed_page.num_values();\n    let num_rows = compressed_page\n        .num_rows()\n        .expect(\"We should have num_rows when we are writing\");\n\n    let header = match &compressed_page {\n        CompressedPage::Data(compressed_page) => assemble_data_page_header(compressed_page),\n        CompressedPage::Dict(compressed_page) => assemble_dict_page_header(compressed_page),\n    }?;\n\n    let header_size = write_page_header(writer, &header)?;\n    let mut bytes_written = header_size;\n\n    bytes_written += match &compressed_page {\n        CompressedPage::Data(compressed_page) => {\n            writer.write_all(&compressed_page.buffer)?;\n            compressed_page.buffer.len() as u64\n        },\n        CompressedPage::Dict(compressed_page) => {\n            writer.write_all(&compressed_page.buffer)?;\n            compressed_page.buffer.len() as u64\n        },","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-parquet/src/parquet/write/page.rs#L45-L81","documentation":"Expect panic in write_page(): the compressed page reports no row count. Nested encodings derive num_rows from parent context; a None here means the page was produced without row information, which the invariant of write_page treats as a writer bug rather than a user error.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"We should have num_rows when we are writing\". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.","commonSituations":"Encountered when input data or configuration does not meet the preconditions of the throwing code path (\"We should have num_rows when we are writing\"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.","solutions":["Internal invariant: num_rows must be known when writing the page; pass the row count through the write options.","Upgrade polars-parquet if this occurs with standard usage."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}