Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transform test for query plan #630

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Conversation

keiko713
Copy link
Contributor

@keiko713 keiko713 commented Nov 7, 2024

Follow-up of #624
While debugging some issue, I noticed that this test exist. To isolate the issue, I started adding the test. While it turned out not to be the collector side issue, I think it won't hurt to expand this test.

@keiko713 keiko713 requested a review from a team November 7, 2024 10:35
@keiko713 keiko713 marked this pull request as draft November 7, 2024 10:50
@keiko713 keiko713 marked this pull request as ready for review November 12, 2024 12:08
@keiko713 keiko713 merged commit 903fc2c into main Nov 13, 2024
3 checks passed
@keiko713 keiko713 deleted the add-transform-test-for-queryplan branch November 13, 2024 02:28
@msakrejda
Copy link
Contributor

I think it may have hurt to expand this test. It maybe caused this Release failure (NBD, but inconvenient). I find the expectedAlt mechanism here completely impossible to maintain, so on second thought, maybe we shouldn't touch this: should we consider reverting?

Maybe if we touch anything here, we should refactor this first, to find another way to avoid this diff issue. Maybe we should just sort these arrays before printing them?

@seanlinsley
Copy link
Member

Maybe the results could be sorted before they're serialized to JSON with sort.SliceStable? I fixed a similar issue in #618 recently (the code already called sort.SliceStable but it was building the logFileContent expected result before the sorting occurred).

msakrejda added a commit that referenced this pull request Nov 26, 2024
Since snapshots include query references and query plan references,
and since those can be orderered nondeterministically, the test can
fail if the snapshot is built with fields in an unexpected order.

The existing test tries to account for that by enumerating all
possible combinations, but this is very difficult to maintain, and
very difficult to scale to additional fields with this pattern.

Instead, rewrite snapshots to a canonical format to ensure comparisons
are stable. We can't just sort the array fields before serializing the
snapshot for comparison, since QueryReferences and similar items are
referenced by an index into their array. To work around that, we sort
the QueryReferences (tracking their original index), and rewrite all
entries that reference them to reference their new index instead.

See discussion in #630 [1].

[1]: #630 (comment)
msakrejda added a commit that referenced this pull request Nov 27, 2024
Since snapshots include query references and query plan references,
and since those can be orderered nondeterministically, the test can
fail if the snapshot is built with fields in an unexpected order.

The existing test tries to account for that by enumerating all
possible combinations, but this is very difficult to maintain, and
very difficult to scale to additional fields with this pattern.

Instead, rewrite snapshots to a canonical format to ensure comparisons
are stable. We can't just sort the array fields before serializing the
snapshot for comparison, since QueryReferences and similar items are
referenced by an index into their array. To work around that, we sort
the QueryReferences (tracking their original index), and rewrite all
entries that reference them to reference their new index instead.

See discussion in #630 [1].

[1]: #630 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants