Skip to content

Commit 23359b5

Browse files
Fix UT fail
1 parent 18e18a2 commit 23359b5

File tree

1 file changed

+18
-0
lines changed
  • x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext

1 file changed

+18
-0
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext/KnnTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Map;
3232
import java.util.function.Supplier;
3333

34+
import static org.elasticsearch.xpack.esql.SerializationTestUtils.assertSerialization;
3435
import static org.elasticsearch.xpack.esql.SerializationTestUtils.serializeDeserialize;
3536
import static org.elasticsearch.xpack.esql.core.type.DataType.BOOLEAN;
3637
import static org.elasticsearch.xpack.esql.core.type.DataType.DENSE_VECTOR;
@@ -144,4 +145,21 @@ protected Expression serializeDeserializeExpression(Expression expression) {
144145
// Fields use synthetic sources, which can't be serialized. So we use the originals instead.
145146
return newExpression.replaceChildren(expression.children());
146147
}
148+
149+
public void testSerializationOfSimple() {
150+
// do nothing
151+
assumeTrue("can't serialize function", canSerialize());
152+
Expression expression = buildFieldExpression(testCase);
153+
if (expression instanceof Knn knn) {
154+
// The K parameter is not serialized, so we need to remove it from the children
155+
// before we compare the serialization results
156+
List<Expression> newChildren = knn.children();
157+
newChildren.set(2, null); // remove the k parameter
158+
Expression knnWithoutK = knn.replaceChildren(newChildren);
159+
assertSerialization(knnWithoutK, testCase.getConfiguration());
160+
} else {
161+
// If not a Knn instance we fail the test as it is supposed to be a Knn function
162+
fail("Expression is not Knn");
163+
}
164+
}
147165
}

0 commit comments

Comments
 (0)