-
Notifications
You must be signed in to change notification settings - Fork 19
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(ontology): refactor to 'lazy' ontology input and filter so heavy lifting is moved to backend and we don't need to download complete ontologies #4584
base: master
Are you sure you want to change the base?
Conversation
…ontology_subtree_filter
…ontology_subtree_filter
…ontology_subtree_filter
@@ -1,7 +1,6 @@ | |||
package org.molgenis.emx2.sql; |
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.
restructured this file so more changes than needed but I hope will make this huge file more easy to understand
@@ -99,30 +99,29 @@ void testToJsonb() throws JsonProcessingException { | |||
String trailingData = "{\"key\":\"value\"}trailing"; | |||
int invalidJavaType = 1; | |||
|
|||
assertAll( | |||
// valid: object |
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.
refactor so individual errors are shown
docs/molgenis/dev_graphql.md
Outdated
@@ -638,6 +638,7 @@ the following function are available: | |||
- textSearch(value) | |||
- between(value) | |||
- notBetween(value) | |||
- _match_any_in_subtree(name) - use this to filter in ontology columns matching also when overlap exists in children of 'name' term |
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.
todo update docs with all these changes
use case not coverered is when a data entry says 'select all cancers' and then I search for 'a specific cancer'. |
|
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.
I think it would be useful to go trough the SqlQuery and the actual sql function together, because it's hard for me to fully understand what is going on
.name("MolgenisIsNotNullEnum") | ||
.value(IsNullOrNotNull.NULL.name(), IsNullOrNotNull.NULL) | ||
.value(IsNullOrNotNull.NOT_NULL.name(), IsNullOrNotNull.NOT_NULL) | ||
.build(); | ||
private static GraphQLObjectType fileDownload = |
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.
Just for my knowledge: Does an enum give you a certain behaviour as a graphql type?
filterBuilder.field( | ||
GraphQLInputObjectField.newInputObjectField() | ||
.name(FILTER_IS) | ||
.type(isNullOrNotNullEnum) |
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.
Ah here we go, the enum gives you fixed options
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.
Wouldn't it make more sense to make this a boolean operator _is_null true false?
value.remove(FILTER_CONTAINS_ALL); | ||
} | ||
|
||
if (value.size() == 0) continue; |
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.
This function is getting a bit chunky
String result = | ||
execute("{Pet(filter:{tags:{_match_any_including_children:\"colors\"}}){name}}").toString(); | ||
assertTrue(result.contains("tom")); | ||
assertFalse(result.contains("pooky")); // poor pooky has no color |
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.
sad
column, | ||
DSL.select( | ||
field( | ||
"\"MOLGENIS\".get_terms_including_children({0},{1},{2})", |
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.
This is nice, you delegated it to the db
.map( | ||
value -> | ||
condition( | ||
"0 < ( SELECT COUNT(*) FROM unnest({1}) AS v WHERE to_tsquery({0}) @@ to_tsvector(v)", |
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.
I do not fully comprehend this
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.
Haven't gone through it all yet, but here are some comments of what I've found thus far.
@@ -286,6 +287,7 @@ export default { | |||
this.key++; | |||
}, | |||
deselect(item: string) { | |||
console.log("haat " + item); |
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.
don't forget to remove
filter[col.id] = { equals: conditions }; | ||
} else if (col.columnType.startsWith("ONTOLOGY")) { | ||
filter[col.id] = { | ||
match_including_children: conditions.map((term) => term.name), |
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.
TS error, term
is supposed to be a string, so term.name
is not possible
@@ -577,6 +637,51 @@ public static FilterBean[] convertMapToFilterArray( | |||
+ " unknown in table " | |||
+ table.getTableName()); | |||
Column c = optional.get(); | |||
Map value = (Map) entry.getValue(); |
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.
This function is quite rough to read due to it's logical complexity. I suggest moving the content of the outer ifs (the ones starting on line 595) to functions to make it more clear what is going on.
} | ||
|
||
@Test | ||
void testNullAndNotNullt() throws IOException { |
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.
Nullt?
.as(name(convertToPascalCase(select.getColumn())))); | ||
} | ||
|
||
// asemble final query |
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.
assemble
SelectConnectByStep<org.jooq.Record> from = | ||
fromQuery(table, List.of(asterisk()), column, tableAlias, subAlias, filters, searchTerms); | ||
from = applyLimitOffsetOrderBy(table, select, from, subAlias); |
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.
Having a far immediately be overwritten by a modified version feels a bit weird. Suggest first assigning an intermediate var and have from
not be overwritten.
What are the main changes you did
N.B. blocks on some of the changes from #4539
How to test
Checklist
Do later