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

Compound filter targeting related indexed field errors #2572

Closed
AndrewSisley opened this issue Apr 30, 2024 · 0 comments · Fixed by #2575
Closed

Compound filter targeting related indexed field errors #2572

AndrewSisley opened this issue Apr 30, 2024 · 0 comments · Fixed by #2575
Assignees
Labels
area/query Related to the query component bug Something isn't working priority/high
Milestone

Comments

@AndrewSisley
Copy link
Contributor

AndrewSisley commented Apr 30, 2024

Querying with a compound (and/or) filter targeting related indexed field errors.

  • This happens with or without data in the database.
  • the compound operator can be either _and or _or, omitting the compound operator does not result in an error.
  • The error occurs whether the index is unique or not.
  • The kind of simple operator in the filter (e.g. _ilike, _eq, etc) does not appear to matter.

For example:

func TestFoo(t *testing.T) {
	test := testUtils.TestCase{
		Actions: []any{
			testUtils.SchemaUpdate{
				Schema: `
				  type Program {
					name: String
					certificationBodyOrg: Organization
				  }

				  type Organization {
					name: String @index
					programs: [Program]
				  }`,
			},
			testUtils.Request{
				Request: `query {
					Program(
					  filter: {
						_and: [
							{ certificationBodyOrg: { name: { _ilike: "%Test3%" } } }
						]
					  }
					) {
					  name
					}
				  }`,
				ExpectedError: "invalid filter operator is provided. Operator: _any",
			},
		},
	}

	testUtils.ExecuteTestCase(t, test)
}

Bug is hitting ln 661 and then 689 in indexer_iterators.go, func IndexFetcher.determineFieldFilterConditions(). That function does not appear to have been written with compound operators in mind. In the above test case ln 659 is hit, but ln 663 is not.

@AndrewSisley AndrewSisley added bug Something isn't working area/query Related to the query component priority/high labels Apr 30, 2024
@AndrewSisley AndrewSisley self-assigned this May 1, 2024
@AndrewSisley AndrewSisley added this to the DefraDB v0.11 milestone May 1, 2024
AndrewSisley added a commit that referenced this issue May 2, 2024
## Relevant issue(s)

Resolves #2572

## Description

Handles compound filters targeting related indexed fields, and one-many
joins from the many side.

The invertableJoin issue may be affecting non indexed joins.

There is another issue in this space not solved by this PR:
#2574
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 bug Something isn't working priority/high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant