{"record":{"id":"0083842344954e8b","repo":"dbt-labs/dbt-core","slug":"table-rename-renamed-rows-length-does-not-ma","errorCode":null,"errorMessage":"Table.rename: renamed_rows length ({}) does not match number of rows ({})","messagePattern":"Table\\.rename: renamed_rows length \\((.+?)\\) does not match number of rows \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table.rs","lineNumber":810,"sourceCode":"        renamed_rows: Option<Arc<StringViewArray>>,\n        slug_columns: bool,\n        slug_rows: bool,\n    ) -> Result<AgateTable, Error> {\n        if let Some(ref columns) = renamed_columns {\n            if columns.len() != self.num_columns() {\n                return Err(Error::new(\n                    ErrorKind::InvalidArgument,\n                    format!(\n                        \"Table.rename: renamed_columns length ({}) does not match number of columns ({})\",\n                        columns.len(),\n                        self.num_columns()\n                    ),\n                ));\n            }\n        }\n        if let Some(ref rows) = renamed_rows {\n            if rows.len() != self.num_rows() {\n                return Err(Error::new(\n                    ErrorKind::InvalidArgument,\n                    format!(\n                        \"Table.rename: renamed_rows length ({}) does not match number of rows ({})\",\n                        rows.len(),\n                        self.num_rows()\n                    ),\n                ));\n            }\n        }\n\n        if slug_columns || slug_rows {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                \"Table.rename: slugging columns or rows is not implemented yet\",\n            ));\n        }\n\n        let repr = if let Some(renamed_columns) = renamed_columns {","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table.rs#L792-L828","documentation":"Table.rename validates that a provided renamed_rows array has exactly one entry per row of the table. A length mismatch was found, so positional row renaming would be ambiguous and the call is rejected.","triggerScenarios":"Calling rename with renamed_rows whose length differs from the table's row count, e.g. renaming a 10-row table with a 4-element array.","commonSituations":"Renaming rows after a filter/aggregate changed the row count; hardcoding lengths from a snapshot of the data; concatenating partial name lists.","solutions":["Build the renamed_rows array from the table's current row count (num_rows) right before calling rename.","Use the map form for row_names to rename only specific rows.","Re-check any upstream filtering/aggregation that changed the number of rows."],"exampleFix":"// before\nrename(None, Some(vec![\"r0\", \"r1\"]), false, false) // table has 5 rows\n// after\nrename(None, Some(vec![\"r0\", \"r1\", \"r2\", \"r3\", \"r4\"]), false, false)","handlingStrategy":"validation","validationCode":"if renamed_rows.len() != table.num_rows() {\n    return Err(format!(\"expected {} row names, got {}\", table.num_rows(), renamed_rows.len()));\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"renamed_rows length\") => {\n        eprintln!(\"{e}; rebuild row name list from table.num_rows()\");\n        // rebuild names and retry\n    }\n    other => other?,\n}","preventionTips":["Build row name arrays immediately after the last filtering/aggregation step.","Prefer the map form when renaming only some rows.","Never cache row name lists across transformations that change row counts."],"tags":["argument-validation","rename","length-mismatch"],"backgroundTag":"invalid-argument-value","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}