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

feat: Add support for one sided relations #3021

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #2830

Description

Adds support for one sided relations.

I thought we had this a while back, but David discovered otherwise.

@AndrewSisley AndrewSisley added feature New feature or request area/query Related to the query component labels Sep 17, 2024
@AndrewSisley AndrewSisley added this to the DefraDB v0.14 milestone Sep 17, 2024
@AndrewSisley AndrewSisley requested a review from a team September 17, 2024 16:21
@AndrewSisley AndrewSisley self-assigned this Sep 17, 2024
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.44%. Comparing base (f5b67e4) to head (df324b0).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
internal/planner/type_join.go 85.71% 2 Missing and 2 partials ⚠️
internal/planner/planner.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3021      +/-   ##
===========================================
+ Coverage    79.39%   79.44%   +0.05%     
===========================================
  Files          331      331              
  Lines        25680    25686       +6     
===========================================
+ Hits         20387    20404      +17     
+ Misses        3834     3827       -7     
+ Partials      1459     1455       -4     
Flag Coverage Δ
all-tests 79.44% <81.25%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/planner/planner.go 83.16% <50.00%> (-0.59%) ⬇️
internal/planner/type_join.go 82.00% <85.71%> (+0.67%) ⬆️

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f5b67e4...df324b0. Read the comment docs.

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for fixing this.

// The field definition of the relation-object field on this side of the relation.
//
// This will always have a value on the primary side, but it may not have a value on
// the secondary side, as the secondary half of the relation is optional.
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: I look forward to the secondary side being handle automatically with the proposed handling of relationship from the primary side.

@@ -286,6 +286,11 @@ func findFilteredByRelationFields(
}

func (p *Planner) tryOptimizeJoinDirection(node *invertibleTypeJoin, parentPlan *selectTopNode) error {
if !node.childSide.relFieldDef.HasValue() {
// If the relation is one sided we cannot invert the join, so return early
return nil
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: If not too much trouble would be nice to hit this case as it shows not covered right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be dead code, but I'm not sure - the invertable join stuff is quite complex and if it isn't hit by the new test I don't know what will hit it. And I don't want to spend much time on this right now, especially given the pending secondary relation rework Fred mentioned.

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

LGTM, just one suggestion

Copy link
Contributor

@islamaliev islamaliev left a comment

Choose a reason for hiding this comment

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

LGTM!

@AndrewSisley AndrewSisley merged commit 75adf50 into sourcenetwork:develop Sep 18, 2024
41 of 43 checks passed
@AndrewSisley AndrewSisley deleted the 2830-one-sided-rel branch September 18, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

One sided primary relations are not queryable
4 participants