-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Transformations: Fix true inner join in joinByField
transformation
#87409
Conversation
joinByField
transformation
packages/grafana-data/src/transformations/transformers/joinDataFrames.ts
Outdated
Show resolved
Hide resolved
@@ -761,93 +761,6 @@ describe('JOIN Transformer', () => { | |||
}); | |||
}); | |||
|
|||
it('inner joins by time field in reverse order', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not relevant with the new behavior. seriesToColumns
has been deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall!
Test dashboard
Tabular Inner and Outer Join Test-1715211190626.json
docs/sources/panels-visualizations/query-transform-data/transform-data/index.md
Show resolved
Hide resolved
packages/grafana-data/src/transformations/transformers/joinDataFrames.test.ts
Outdated
Show resolved
Hide resolved
packages/grafana-data/src/transformations/transformers/joinDataFrames.test.ts
Show resolved
Hide resolved
* | ||
* @returns {Array<Array<string | number | null | undefined>>} The joined tables as an array of arrays, where each array represents a row in the joined table. | ||
*/ | ||
function joinInner(tables: AlignedData[]): Array<Array<string | number | null | undefined>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function joinInner(tables: AlignedData[]): Array<Array<string | number | null | undefined>> { | |
function joinInnerTabular(tables: AlignedData[]): Array<Array<string | number | null | undefined>> { |
Should we keep naming convention the same as the outer join for tabular data? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: it seems that for inner we can do both series + tabular data while for some reason outer is differentiated and split out 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I was originally going to add an INNER (TABULAR)
option, but the previous INNER
wasn't actually behaving like an INNER
anyway, so instead of adding yet another option, @leeoniya suggested we just correct the original INNER
's behavior, which I think was the right move. The reason we split the 2 OUTER
joins - I believe - is because they behave significantly differently then the other, depending on the data (time series or SQL-like). The INNER
, however, due to the nature of an INNER
join itself, will behave very similarly for both data types - sans a few edge cases.
packages/grafana-data/src/transformations/transformers/joinDataFrames.ts
Show resolved
Hide resolved
docs/sources/panels-visualizations/query-transform-data/transform-data/index.md
Show resolved
Hide resolved
…aFrames.test.ts Co-authored-by: Nathan Marrs <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave it a spin and looks good! 🚀
What is this feature?
This fixes the joinByField's "inner" join option to perform like an actual SQL-like inner join.
Example:
Students
Enrollments
The result after applying the inner join transformation looks like the following:
The inner join only includes rows where there is a match between the "StudentID" in both tables. In this case, the result does not include "Jennifer" from the "Students" table because there are no matching enrollments for her in the "Enrollments" table.
Why do we need this feature?
It is used by users, but has not been working as expected. Also, an escalation was created for it.
Who is this feature for?
All users.
Which issue(s) does this PR fix?:
Fixes #87361
Special notes for your reviewer:
Please check that: