aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2019-07-15 11:05:17 +0200
committerGitHub <noreply@github.com>2019-07-15 11:05:17 +0200
commitb120c86034342e38a71ca684a8391c34452e4f01 (patch)
tree38b5d452c5ef2a6cf4b8bb0054bf53b41801049b
parentec17f2b9d074a8d96a3372c55064aa2591586ba0 (diff)
Revert "Setting attribute on a field that has struct or map sub-type(s) is no…"
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java21
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java30
2 files changed, 0 insertions, 51 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
index c4e0f4cafef..8b523211471 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
@@ -463,33 +463,12 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
}
}
}.visit(indexingScript);
- } else {
- if (!getDataType().equals(PositionDataType.INSTANCE) &&
- !getDataType().equals(DataType.getArray(PositionDataType.INSTANCE)) &&
- hasAttributeExpression(exp))
- {
- throw new IllegalArgumentException("For field '" + getName() + "': Setting attribute on a field that has struct or map sub-type(s) is not supported");
- }
}
for (SDField structField : getStructFields()) {
structField.setIndexingScript(exp);
}
}
- private static boolean hasAttributeExpression(ScriptExpression exp) {
- var visitor = new ExpressionVisitor() {
- boolean result = false;
- @Override
- protected void doVisit(Expression exp) {
- if (exp instanceof AttributeExpression) {
- result = true;
- }
- }
- };
- visitor.visit(exp);
- return visitor.result;
- }
-
@Override
public ScriptExpression getIndexingScript() {
return indexingScript;
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java
index a0c05193661..3ba3745f46e 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidatorTestCase.java
@@ -49,36 +49,6 @@ public class ComplexAttributeFieldsValidatorTestCase {
}
@Test
- public void throws_when_attribute_is_set_on_a_field_with_struct_sub_type() throws IOException, SAXException {
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For field 'struct_array.f2': Setting attribute on a field that has struct or map sub-type(s) is not supported");
- createModelAndValidate(joinLines(createSearchDefintionWithInvalidStructFieldAttribute("array<s1>")));
- }
-
- @Test
- public void throws_when_attribute_is_set_on_a_field_with_map_sub_type() throws IOException, SAXException {
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For field 'struct_array.f2': Setting attribute on a field that has struct or map sub-type(s) is not supported");
- createModelAndValidate(joinLines(createSearchDefintionWithInvalidStructFieldAttribute("map<string, int>")));
- }
-
- private String createSearchDefintionWithInvalidStructFieldAttribute(String invalidFieldType) {
- return joinLines("search test {",
- " document test {",
- " struct s1 {",
- " field f1 type int {}",
- " }",
- " struct s2 {",
- " field f2 type " + invalidFieldType + " {}",
- " }",
- " field struct_array type array<s2> {",
- " struct-field f2 { indexing: attribute }",
- " }",
- " }",
- "}");
- }
-
- @Test
public void validation_passes_when_only_supported_struct_field_attributes_are_used() throws IOException, SAXException {
createModelAndValidate(joinLines("search test {",
" document test {",