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

Don't fail early when using reference attribute in grouping expression. #33038

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading