{"record":{"id":"8e41cc4908206cbd","repo":"dbt-labs/dbt-core","slug":"table-limit-e","errorCode":null,"errorMessage":"Table.limit: {e}","messagePattern":"Table\\.limit: (.+?)","errorType":"exception","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table.rs","lineNumber":1343,"sourceCode":"                    require_match,\n                    columns,\n                )?;\n                Ok(Value::from_object(table))\n            }\n            // ```python\n            // def limit(self, start_or_stop=None, stop=None, step=None):\n            //     \"\"\"\n            //     Filter data to a subset of all rows.\n            //     \"\"\"\n            // ```\n            //\n            // Only the single-arg `limit(n)` form is supported on the rust port.\n            \"limit\" => {\n                let iter = ArgsIter::new(\"Table.limit\", &[\"n\"], args);\n                let n = iter.next_arg::<i64>()?;\n                iter.finish()?;\n                let table = self.as_ref().limit(n).map_err(|e| {\n                    Error::new(ErrorKind::InvalidOperation, format!(\"Table.limit: {e}\"))\n                })?;\n                Ok(Value::from_object(table))\n            }\n            // ```python\n            // def distinct(self, key=None):\n            //     \"\"\"\n            //     Create a new table with only unique rows.\n            //\n            //     :param key:\n            //         Either the name of a single column to use to identify unique rows, a\n            //         sequence of such column names, a :class:`function` that takes a\n            //         row and returns a value to identify unique rows, or `None`, in\n            //         which case the entire row will be checked for uniqueness.\n            //     :returns:\n            //     A new :class:`.Table`.\n            //     \"\"\"\n            // ```\n            \"distinct\" => {","sourceCodeStart":1325,"sourceCodeEnd":1361,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table.rs#L1325-L1361","documentation":"Thrown by the `Table.limit()` method binding when the underlying `limit(n)` operation fails, wrapping the inner error as an InvalidOperation error prefixed with `Table.limit:`. Note only the single-argument `limit(n)` form is supported in the Rust port; failures come from the internal row-slicing step.","triggerScenarios":"Calling `table.limit(n)` where the internal `limit` implementation returns an error — e.g. an out-of-range or negative `n` rejected by the implementation, or an internal slicing failure.","commonSituations":"Computing the limit from a variable that is negative or zero; porting Python agate code that used `limit(n=..., offset=...)` (unsupported form here) or passing oversized counts.","solutions":["Read the wrapped inner message after `Table.limit:` for the root cause","Ensure `n` is a non-negative integer within the table's row count","Use only the single-argument form `limit(n)`; the two-arg form is unsupported in this port","Guard the value before calling: `if n >= 0 { table.limit(n) }`"],"exampleFix":"// before\ntable.limit(-5)\n// after\nlet n = 5; // must be >= 0\ntable.limit(n)","handlingStrategy":"validation","validationCode":"if not isinstance(n, int) or n < 0:\n    raise ValueError(f'limit n must be a non-negative int, got {n!r}')","typeGuard":"null","tryCatchPattern":"try:\n    limited = table.limit(n)\nexcept Exception as e:\n    if str(e).startswith('Table.limit:'):\n        raise ValueError(f'invalid limit n={n!r}: {e}') from e\n    raise","preventionTips":["Clamp n to max(0, n) and table.num_rows before limiting","Use only the single-argument limit(n) form in this port","Avoid computed limits from potentially negative variables"],"tags":["rust","data-table","argument-validation"],"backgroundTag":"argument-out-of-range","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}