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 and-or inline array aggregate filters #779

Merged
merged 2 commits into from
Sep 8, 2022

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #621

Description

Adds support for and-or in inline array aggregate filters. Also fixes a bug where the underling type (e.g. Int) was set as the type param for normal-non-aggregate filters on inline arrays (tested via tests when adding the main feature, fix-commit does not contain tests that covers this).

Specify the platform(s) on which this was tested:

  • Debian Linux

Was incorrectly typing the filter parameter as the underlyering type, not a list. This feature can be added in properly later (also only added for nillable types, non-nillables fail the isLeaf type check for some horrible reason).
@AndrewSisley AndrewSisley added feature New feature or request area/query Related to the query component area/schema Related to the schema system action/no-benchmark Skips the action that runs the benchmark. labels Sep 7, 2022
@AndrewSisley AndrewSisley added this to the DefraDB v0.3.1 milestone Sep 7, 2022
@AndrewSisley AndrewSisley requested a review from a team September 7, 2022 20:56
@AndrewSisley AndrewSisley self-assigned this Sep 7, 2022
@AndrewSisley AndrewSisley force-pushed the sisley/feat/I621-agg-filter-and-or branch from e7a1c47 to e8fdc7f Compare September 7, 2022 20:56
@AndrewSisley AndrewSisley changed the title feat: Add support for and-or in inline array aggregate filters feat: Add support for and-or inline array aggregate filters Sep 7, 2022
@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Merging #779 (8ccc4a7) into develop (16c30b9) will increase coverage by 0.09%.
The diff coverage is 82.60%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #779      +/-   ##
===========================================
+ Coverage    58.53%   58.63%   +0.09%     
===========================================
  Files          150      150              
  Lines        16900    16967      +67     
===========================================
+ Hits          9893     9948      +55     
- Misses        6083     6093      +10     
- Partials       924      926       +2     
Impacted Files Coverage Δ
query/graphql/schema/generate.go 82.98% <79.31%> (-0.27%) ⬇️
query/graphql/schema/manager.go 97.34% <100.00%> (+0.28%) ⬆️

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! Praise for easy to review code of solid quality.

Name: fmt.Sprintf("%s%s", filterTypeName, "FilterArg"),
}

fieldThunk := (gql.InputObjectConfigFieldMapThunk)(
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: why the extra parenthesis arount the function name?

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 is casting the anon function, although I think the cast might be avoidable with explicit typing of the variable declaration - will give it a quick go before merging - thanks :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes I missed that it was a type and not a function. But yes indeed explicit typing would work:

var fieldThunk gql.InputObjectConfigFieldMapThunk
fieldThunk = func() (gql.InputObjectConfigFieldMap, error) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

actually you can avoid the type casting and the explicit typing. Just do:

fieldThunk := func() (gql.InputObjectConfigFieldMap, error) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nevermind. fieldThunk needs an explicit type. I though for a minute that it would work cuz it compiled but we get a runtime error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, the thunk stuff is a bit unsafe like that :( merging with the explicit type

@AndrewSisley AndrewSisley force-pushed the sisley/feat/I621-agg-filter-and-or branch from e8fdc7f to 8ccc4a7 Compare September 8, 2022 00:11
Name: fmt.Sprintf("%s%s", filterTypeName, "FilterArg"),
}

var fieldThunk gql.InputObjectConfigFieldMapThunk = func() (gql.InputObjectConfigFieldMap, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

praise: I like this much better :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for spotting it

@AndrewSisley AndrewSisley merged commit 5448e25 into develop Sep 8, 2022
@AndrewSisley AndrewSisley deleted the sisley/feat/I621-agg-filter-and-or branch September 8, 2022 00:27
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
…twork#779)

* Remove broken inline array filter param

Was incorrectly typing the filter parameter as the underlyering type, not a list. This feature can be added in properly later (also only added for nillable types, non-nillables fail the isLeaf type check for some horrible reason).

* Add and-or support for inline array agg filters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/query Related to the query component area/schema Related to the schema system feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aggregate: And/Or for inline array filters
2 participants