Skip to content

Commit

Permalink
perf: Reduce compute in error message for failed datetime parsing (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Oct 31, 2023
1 parent e592b16 commit 81e9be6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/polars-plan/src/dsl/function_expr/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,8 @@ fn handle_temporal_parsing_error(
) -> PolarsResult<()> {
let failure_mask = !ca.is_null() & out.is_null();
let all_failures = ca.filter(&failure_mask)?;
let first_failures = all_failures.unique()?.slice(0, 10).sort(false);
let first_failures = all_failures.slice(0, 3);
let n_failures = all_failures.len();
let n_failures_unique = all_failures.n_unique()?;
let exact_addendum = if has_non_exact_option {
"- setting `exact=False` (note: this is much slower!)\n"
} else {
Expand All @@ -446,15 +445,14 @@ fn handle_temporal_parsing_error(
}
polars_bail!(
ComputeError:
"strict {} parsing failed for {} value(s) ({} unique): {}\n\
"strict {} parsing failed for {} value(s) (first few failures: {})\n\
\n\
You might want to try:\n\
- setting `strict=False`\n\
{}\
{}",
out.dtype(),
n_failures,
n_failures_unique,
first_failures.into_series().fmt_list(),
exact_addendum,
format_addendum,
Expand Down

0 comments on commit 81e9be6

Please sign in to comment.