From 73dfed8f2c63c8e0db2d834ed23c688bf84d3101 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Tue, 19 Dec 2023 18:30:55 +0100 Subject: [PATCH] When cartesian decoding fails, we should test and mimic that failure --- .../scalar/convert/ToCartesianPointTests.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianPointTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianPointTests.java index c27671970a6b5..d0039575a74a9 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianPointTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianPointTests.java @@ -38,15 +38,23 @@ public static Iterable parameters() { final List suppliers = new ArrayList<>(); TestCaseSupplier.forUnaryCartesianPoint(suppliers, attribute, EsqlDataTypes.CARTESIAN_POINT, l -> l, List.of()); - TestCaseSupplier.forUnaryLong( - suppliers, - evaluatorName.apply("FromLong"), - EsqlDataTypes.CARTESIAN_POINT, - CARTESIAN::longAsPoint, - Long.MIN_VALUE, - Long.MAX_VALUE, - List.of() - ); + TestCaseSupplier.forUnaryLong(suppliers, evaluatorName.apply("FromLong"), EsqlDataTypes.CARTESIAN_POINT, l -> { + try { + return CARTESIAN.longAsPoint(l); + } catch (IllegalArgumentException e) { + return null; + } + }, Long.MIN_VALUE, Long.MAX_VALUE, l -> { + try { + CARTESIAN.longAsPoint(l.longValue()); + return List.of(); + } catch (IllegalArgumentException e) { + return List.of( + "Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.", + "Line -1:-1: " + e.getMessage() + ); + } + }); // random strings that don't look like a cartesian point TestCaseSupplier.forUnaryStrings( suppliers,