Skip to content

Commit

Permalink
Merge pull request #33038 from vespa-engine/geirst/grouping-reference…
Browse files Browse the repository at this point in the history
…-attribute-validation

Don't fail early when using reference attribute in grouping expression.
  • Loading branch information
hmusum authored Dec 13, 2024
2 parents 8307d1d + e43e137 commit 2cce992
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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 '" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2cce992

Please sign in to comment.