diff options
author | Lester Solbakken <lesters@oath.com> | 2020-01-13 14:31:13 +0100 |
---|---|---|
committer | Lester Solbakken <lesters@oath.com> | 2020-01-13 14:31:13 +0100 |
commit | 978e4137817f6c7f81a74ebda15d41545b723993 (patch) | |
tree | 026fdda1c0a8cd064fe6ced70546fb22ce30f32c | |
parent | eecd29687f03227071c77987733a100c3e19057e (diff) |
Revert "Revert "Lesters/resolve input types for stateless model evaluation 2""
This reverts commit 1449f771fbbcfc235d88a7b73b51f8b88ebc53cb.
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java index 8fad8695e88..2d0998864f1 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java @@ -50,7 +50,7 @@ public class RankingExpressionTypeResolver extends Processor { resolveTypesIn(profile, validate); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("In " + search + ", " + profile, e); + throw new IllegalArgumentException("In " + (search != null ? search + ", " : "") + profile, e); } } } @@ -63,10 +63,19 @@ public class RankingExpressionTypeResolver extends Processor { private void resolveTypesIn(RankProfile profile, boolean validate) { MapEvaluationTypeContext context = profile.typeContext(queryProfiles); for (Map.Entry<String, RankProfile.RankingExpressionFunction> function : profile.getFunctions().entrySet()) { - if (hasUntypedArguments(function.getValue().function())) continue; - TensorType type = resolveType(function.getValue().function().getBody(), - "function '" + function.getKey() + "'", - context); + ExpressionFunction expressionFunction = function.getValue().function(); + if (hasUntypedArguments(expressionFunction)) continue; + + // Add any missing inputs for type resolution + for (String argument : expressionFunction.arguments()) { + Reference ref = Reference.fromIdentifier(argument); + if (context.getType(ref).equals(TensorType.empty)) { + context.setType(ref, expressionFunction.argumentTypes().get(argument)); + } + } + context.forgetResolvedTypes(); + + TensorType type = resolveType(expressionFunction.getBody(), "function '" + function.getKey() + "'", context); function.getValue().setReturnType(type); } |