aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-09-29 22:00:35 +0200
committerJon Bratseth <bratseth@gmail.com>2022-09-29 22:00:35 +0200
commit3c87c6cbb24ec5531d692eea83468b61f9e7a30a (patch)
tree1e2d7c8b5602d9913c0dc0cb490e52200206d41f /config-model
parent0b08f84d1a2bc9fcbea0656d33e5e23f3e325e40 (diff)
Tolerate missing types
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java41
-rw-r--r--config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java19
2 files changed, 38 insertions, 22 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java b/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java
index 11bd14cbe46..8b07aa48a24 100644
--- a/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java
+++ b/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java
@@ -66,26 +66,31 @@ public class DerivedConfiguration implements AttributesConfig.Producer {
* schema is later modified.
*/
public DerivedConfiguration(Schema schema, DeployState deployState) {
- Validator.ensureNotNull("Schema", schema);
- this.schema = schema;
- this.queryProfiles = deployState.getQueryProfiles().getRegistry();
- this.maxUncommittedMemory = deployState.getProperties().featureFlags().maxUnCommittedMemory();
- if ( ! schema.isDocumentsOnly()) {
- streamingFields = new VsmFields(schema);
- streamingSummary = new VsmSummary(schema);
+ try {
+ Validator.ensureNotNull("Schema", schema);
+ this.schema = schema;
+ this.queryProfiles = deployState.getQueryProfiles().getRegistry();
+ this.maxUncommittedMemory = deployState.getProperties().featureFlags().maxUnCommittedMemory();
+ if (!schema.isDocumentsOnly()) {
+ streamingFields = new VsmFields(schema);
+ streamingSummary = new VsmSummary(schema);
+ }
+ if (!schema.isDocumentsOnly()) {
+ attributeFields = new AttributeFields(schema);
+ summaries = new Summaries(schema, deployState.getDeployLogger(), deployState.getProperties().featureFlags());
+ juniperrc = new Juniperrc(schema);
+ rankProfileList = new RankProfileList(schema, schema.rankExpressionFiles(), attributeFields, deployState);
+ indexingScript = new IndexingScript(schema);
+ indexInfo = new IndexInfo(schema);
+ schemaInfo = new SchemaInfo(schema, deployState.rankProfileRegistry(), summaries);
+ indexSchema = new IndexSchema(schema);
+ importedFields = new ImportedFields(schema);
+ }
+ Validation.validate(this, schema);
}
- if ( ! schema.isDocumentsOnly()) {
- attributeFields = new AttributeFields(schema);
- summaries = new Summaries(schema, deployState.getDeployLogger(), deployState.getProperties().featureFlags());
- juniperrc = new Juniperrc(schema);
- rankProfileList = new RankProfileList(schema, schema.rankExpressionFiles(), attributeFields, deployState);
- indexingScript = new IndexingScript(schema);
- indexInfo = new IndexInfo(schema);
- schemaInfo = new SchemaInfo(schema, deployState.rankProfileRegistry(), summaries);
- indexSchema = new IndexSchema(schema);
- importedFields = new ImportedFields(schema);
+ catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Invalid " + schema, e);
}
- Validation.validate(this, schema);
}
/**
diff --git a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java
index 25cd7fe7bd2..49fb48225e7 100644
--- a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java
+++ b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/BooleanExpressionTransformer.java
@@ -65,7 +65,7 @@ public class BooleanExpressionTransformer extends ExpressionTransformer<Transfor
ChildNode rhs = stack.pop();
ChildNode lhs = stack.peek();
- boolean primitives = isPrimitive(lhs.child, context) && isPrimitive(rhs.child, context);
+ boolean primitives = isDefinitelyPrimitive(lhs.child, context) && isDefinitelyPrimitive(rhs.child, context);
ExpressionNode combination;
if (primitives && rhs.op == Operator.and)
combination = andByIfNode(lhs.child, rhs.child);
@@ -78,8 +78,20 @@ public class BooleanExpressionTransformer extends ExpressionTransformer<Transfor
lhs.child = combination;
}
- private boolean isPrimitive(ExpressionNode node, TransformContext context) {
- return node.type(context.types()).rank() == 0;
+ private boolean isDefinitelyPrimitive(ExpressionNode node, TransformContext context) {
+ try {
+ return node.type(context.types()).rank() == 0;
+ }
+ catch (IllegalArgumentException e) {
+ // Types can only be reliably resolved top down, which has not done here.
+ // E.g
+ // function(nameArg) {
+ // attribute(nameArg)
+ // }
+ // is supported.
+ // So, we return false when something cannot be resolved.
+ return false;
+ }
}
private static OperationNode resolve(ChildNode left, ChildNode right) {
@@ -108,7 +120,6 @@ public class BooleanExpressionTransformer extends ExpressionTransformer<Transfor
joinedChildren.add(node.child);
}
-
private IfNode andByIfNode(ExpressionNode a, ExpressionNode b) {
return new IfNode(a, b, new ConstantNode(new BooleanValue(false)));
}