Skip to content

fix(thor): Fix error filtering before range aggregations - #20560

Merged
spiridonov merged 5 commits into
mainfrom
spiridonov-errors-columns-bugfix
Jan 26, 2026
Merged

fix(thor): Fix error filtering before range aggregations#20560
spiridonov merged 5 commits into
mainfrom
spiridonov-errors-columns-bugfix

Conversation

@spiridonov

@spiridonov spiridonov commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

I realized that I implemented avg and groupings by and without, but forgot to enable them. When I enabled them some tests started failing on a weird thing. After a long investigation it turned out that:

  • Both json parse and unwrap stages can add __error__ columns into the record, which leads to column duplicate and ambiguity for other stages in processing/filtering rows with errors.
  • No-errors were recorded as nulls. However the filter before range aggregations filters by error == "" which returned false on nulls.

This PR has following changes:

  • Enables avg and various combinations of vector and range aggregations.
  • Records no-errors as empty strings instead of nulls.
  • Merges __error__ columns in project stage.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR
@spiridonov
spiridonov marked this pull request as ready for review January 23, 2026 18:43
@spiridonov
spiridonov requested a review from a team as a code owner January 23, 2026 18:43
@spiridonov
spiridonov enabled auto-merge (squash) January 23, 2026 18:43

@trevorwhitney trevorwhitney left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, my only question is if we would rather concatenate in the case of multiple errors? is there a good reason not to do this and always prefer the one on the right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my understanding of the problem that was fixed here was the input already has an __error__ and __error_details__ column, correct? if so, can we add a test for that case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment thread pkg/engine/internal/executor/project.go Outdated
Comment on lines +199 to +205
fromVal := from.Value(i)
if fromVal != "" {
builder.Append(fromVal)
} else {
builder.Append(to.Value(i))
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why overwrite the existing error instead of concatenating? would it be better to return all the errors we could, or are you worried that would get messy concatenated them together?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to a merge

@spiridonov spiridonov assigned trevorwhitney and unassigned benclive Jan 26, 2026

@trevorwhitney trevorwhitney left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for the change to mergeErrors!

@spiridonov
spiridonov merged commit 514a142 into main Jan 26, 2026
88 of 90 checks passed
@spiridonov
spiridonov deleted the spiridonov-errors-columns-bugfix branch January 26, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants