From e43e13727c8959c893dc23c7bbdf2ea1af9d0664 Mon Sep 17 00:00:00 2001 From: Geir Storli Date: Fri, 13 Dec 2024 10:53:39 +0000 Subject: [PATCH] Don't fail early when using reference attribute in grouping expression. This is not yet supported in the backend, so it still results in an error in the query result. This change is done to unblock some failing tests. --- .../java/com/yahoo/search/grouping/GroupingValidator.java | 7 ++++--- .../yahoo/search/grouping/GroupingValidatorTestCase.java | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java index 70942372d2b..6f9071d1d6b 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java @@ -110,10 +110,11 @@ static private boolean isPrimitiveAttribute(AttributesConfig.Attribute attribute datatype == AttributesConfig.Attribute.Datatype.DOUBLE; } - static private boolean isSingleRawOrBoolAttribute(AttributesConfig.Attribute attribute) { + static private boolean isSingleRawBoolOrReferenceAttribute(AttributesConfig.Attribute attribute) { var datatype = attribute.datatype(); return (datatype == AttributesConfig.Attribute.Datatype.RAW || - datatype == AttributesConfig.Attribute.Datatype.BOOL) && + datatype == AttributesConfig.Attribute.Datatype.BOOL || + datatype == AttributesConfig.Attribute.Datatype.REFERENCE) && attribute.collectiontype() == AttributesConfig.Attribute.Collectiontype.SINGLE; } @@ -122,7 +123,7 @@ private void verifyHasAttribute(String attributeName, boolean isMapLookup) { if (attribute == null) { throw new UnavailableAttributeException(clusterName, attributeName); } - if (isPrimitiveAttribute(attribute) || (!isMapLookup && isSingleRawOrBoolAttribute(attribute))) { + if (isPrimitiveAttribute(attribute) || (!isMapLookup && isSingleRawBoolOrReferenceAttribute(attribute))) { return; } throw new IllegalInputException("Grouping request references attribute '" + diff --git a/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java index de3254d85ad..04006f7ecde 100644 --- a/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java @@ -178,8 +178,8 @@ void predicate_attribute_throws() { } @Test - void reference_attribute_throws() { - unsupported_attribute_type_throws("reference", AttributesConfig.Attribute.Datatype.REFERENCE, "reference"); + void reference_attribute_is_ok() { + validate_attribute_type("reference", AttributesConfig.Attribute.Datatype.REFERENCE); } @Test