Skip to content

Commit

Permalink
backup 1
Browse files Browse the repository at this point in the history
  • Loading branch information
dexamundsen committed Feb 10, 2025
1 parent a7dc747 commit 517cd32
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ public HintQueryResult getEntityLevelHints(
Literal enumVal = sqlRowResult.get(ENUM_VAL_ALIAS, DataType.INT64);
String enumDisplay =
sqlRowResult.get(ENUM_DISP_ALIAS, DataType.STRING).getStringVal();
if (enumDisplay == null) {
enumDisplay = "N/A";
}
Long enumCount =
sqlRowResult.get(ENUM_COUNT_ALIAS, DataType.INT64).getInt64Val();
attrEnumValues.put(new ValueDisplay(enumVal, enumDisplay), enumCount);
Expand All @@ -295,6 +298,9 @@ public HintQueryResult getEntityLevelHints(
.forEachRemaining(
sqlRowResult -> {
Literal enumVal = sqlRowResult.get(ENUM_VAL_ALIAS, DataType.STRING);
if (enumVal.getStringVal() == null) {
enumVal = Literal.forString("N/A");
}
Long enumCount =
sqlRowResult.get(ENUM_COUNT_ALIAS, DataType.INT64).getInt64Val();
attrEnumValues.put(new ValueDisplay(enumVal), enumCount);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bio.terra.tanagra.filterbuilder.impl.core.utils;

import static bio.terra.tanagra.api.filter.BooleanAndOrFilter.newBooleanAndOrFilter;
import static bio.terra.tanagra.filterbuilder.SchemaUtils.toLiteral;
import static bio.terra.tanagra.utils.ProtobufUtils.deserializeFromJsonOrProtoBytes;

Expand Down Expand Up @@ -73,10 +74,7 @@ public static EntityFilter buildForEntity(
underlay, entity, attribute, BinaryOperator.EQUALS, enumLiterals.get(0))
: new AttributeFilter(underlay, entity, attribute, NaryOperator.IN, enumLiterals));
}

return filtersToOr.size() > 1
? new BooleanAndOrFilter(LogicalOperator.OR, filtersToOr)
: filtersToOr.get(0);
return newBooleanAndOrFilter(LogicalOperator.OR, filtersToOr);

} else {
// Numeric range filter.
Expand All @@ -90,8 +88,7 @@ public static EntityFilter buildForEntity(
NaryOperator.BETWEEN,
List.of(Literal.forDouble(range.getMin()), Literal.forDouble(range.getMax()))));
}
return BooleanAndOrFilter.newBooleanAndOrFilter(
BooleanAndOrFilter.LogicalOperator.OR, rangeFilters);
return newBooleanAndOrFilter(BooleanAndOrFilter.LogicalOperator.OR, rangeFilters);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public ITInstanceLevelDisplayHints(
this.orderBys =
ImmutableList.of(
Column.ATTRIBUTE_NAME.getSchema().getColumnName(),
Column.ENTITY_ID.getSchema().getColumnName(),
Column.ENUM_DISPLAY.getSchema().getColumnName(),
Column.ENUM_VALUE.getSchema().getColumnName(),
Column.ENUM_COUNT.getSchema().getColumnName() + " DESC");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void selectAllValueDataFilter() {
EntityFilter cohortFilter = filterBuilder.buildForCohort(underlay, List.of(selectionData));
assertEquals(expectedCohortFilter, cohortFilter);

// Multiple attribute values including n/a in filter
// Multiple attribute values including n/a in filter
ValueData.Selection selection2 =
ValueData.Selection.newBuilder()
.setValue(Value.newBuilder().setStringValue("ghijkl").build())
Expand All @@ -397,7 +397,7 @@ void selectAllValueDataFilter() {
.build();

expectedValueDataSubFilter =
new BooleanAndOrFilter(
newBooleanAndOrFilter(
LogicalOperator.OR,
List.of(
new AttributeFilter(underlay, entity_variant, attribute, UnaryOperator.IS_NULL),
Expand All @@ -412,7 +412,7 @@ void selectAllValueDataFilter() {
expectedSubFilter =
new ItemInGroupFilter(
underlay, groupItems_variant, expectedValueDataSubFilter, List.of(), null, null);
expectedCohortFilter = new BooleanAndOrFilter(LogicalOperator.OR, List.of(expectedSubFilter));
expectedCohortFilter = newBooleanAndOrFilter(LogicalOperator.OR, List.of(expectedSubFilter));

selectionData = new SelectionData(null, serializeToJson(data));
cohortFilter = filterBuilder.buildForCohort(underlay, List.of(selectionData));
Expand Down

0 comments on commit 517cd32

Please sign in to comment.