File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 3131import java .util .Map ;
3232import java .util .function .Supplier ;
3333
34+ import static org .elasticsearch .xpack .esql .SerializationTestUtils .assertSerialization ;
3435import static org .elasticsearch .xpack .esql .SerializationTestUtils .serializeDeserialize ;
3536import static org .elasticsearch .xpack .esql .core .type .DataType .BOOLEAN ;
3637import 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}
You can’t perform that action at this time.
0 commit comments