diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-28 22:54:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 22:54:13 +0200 |
commit | 12992ecdc0e77968eb5c5544f2ae7d855e443162 (patch) | |
tree | ac8cec3ae02f27ae638876940399f490b4ac4ab1 /config-model/src/test/java/com/yahoo/schema/RankingExpressionInliningTestCase.java | |
parent | d50f7bd9c99ed9d8edeabb71825f3966f9cd6bd9 (diff) | |
parent | fb0074925e9e8358d38145dc5753de1c935f737d (diff) |
Merge pull request #24251 from vespa-engine/bratseth/operatorsv8.61.17
Bratseth/operators
Diffstat (limited to 'config-model/src/test/java/com/yahoo/schema/RankingExpressionInliningTestCase.java')
-rw-r--r-- | config-model/src/test/java/com/yahoo/schema/RankingExpressionInliningTestCase.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/schema/RankingExpressionInliningTestCase.java index 5eecee516ec..13d21884c7d 100644 --- a/config-model/src/test/java/com/yahoo/schema/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/RankingExpressionInliningTestCase.java @@ -68,7 +68,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { Schema s = builder.getSchema(); RankProfile parent = rankProfileRegistry.get(s, "parent").compile(new QueryProfileRegistry(), new ImportedMlModels()); - assertEquals("7.0 * (3 + attribute(a) + attribute(b) * (attribute(a) * 3 + if (7.0 < attribute(a), 1, 2) == 0))", + assertEquals("7.0 * (3 + attribute(a) + attribute(b) * (attribute(a) * 3 + (if (7.0 < attribute(a), 1, 2) == 0)))", parent.getFirstPhaseRanking().getRoot().toString()); RankProfile child = rankProfileRegistry.get(s, "child").compile(new QueryProfileRegistry(), new ImportedMlModels()); assertEquals("7.0 * (9 + attribute(a))", @@ -76,6 +76,33 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { } @Test + void testInlinedComparison() throws ParseException { + RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); + ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); + builder.addSchema("search test {\n" + + " document test { \n" + + " }\n" + + " \n" + + " rank-profile parent {\n" + + "function foo() {\n" + + " expression: 3 * bar\n" + + "}\n" + + "\n" + + "function inline bar() {\n" + + " expression: query(test) > 2.0\n" + + "}\n" + + "}\n" + + "}\n"); + builder.build(true); + Schema s = builder.getSchema(); + + RankProfile parent = rankProfileRegistry.get(s, "parent").compile(new QueryProfileRegistry(), new ImportedMlModels()); + assertEquals("3 * (query(test) > 2.0)", + parent.getFunctions().get("foo").function().getBody().getRoot().toString()); + + } + + @Test void testConstants() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); |