From fa1cf1129e61470ad65e22f4d08a82cf28868205 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 5 Oct 2026 09:01:31 +0200 Subject: [PATCH] Let the SQL surface tests report a MEOS error as JMEOS raises it GeneratedSqlSurfaceTest and SqlSurfaceOverUdfSurfaceTest install no MEOS error handler and neither initialise nor finalise MEOS: every GeneratedFunctions wrapper runs GeneratedFunctions.ensureReady() first, which initialises MEOS once per process and installs MeosErrorHandler, and reads MeosErrorHandler.checkError() after the call, which rethrows the error MEOS reported as a typed MeosException. A handler installed over MeosErrorHandler records nothing, so a failed call answers false or NULL, and meos_initialize() puts back MEOS's default handler, which ends the process; a finalization frees the timezone and collation of the thread that ensureReady() does not set up again. Each test stops its Spark session after its tests. Measured against MobilityDB master c435dc7863, the catalog of MEOS-API 993b4dbacf and the jar of JMEOS main bc444c92: the 34 tests pass and the build prints no warning. Why: MEOS reports an error through the handler JMEOS installs, so a test leaves that handler in place and receives the error as the exception it raises. --- .../java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java | 6 +----- .../org/mobilitydb/spark/SqlSurfaceOverUdfSurfaceTest.java | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java b/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java index ca1ff2cb..6668daf0 100644 --- a/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java +++ b/src/test/java/org/mobilitydb/spark/GeneratedSqlSurfaceTest.java @@ -57,9 +57,6 @@ class GeneratedSqlSurfaceTest { @BeforeAll static void init() { - // No-op error handler so a parse error returns rather than terminating the JVM. - GeneratedFunctions.meos_initialize_error_handler((level, code, message) -> { }); - GeneratedFunctions.meos_initialize(); tfloat = "tfloatFromHexWKB('" + TFloat.encode(GeneratedFunctions.tfloat_in( "[1@2020-01-01 00:00:00+00, 3@2020-01-03 00:00:00+00]")) + "')"; tint = "tintFromHexWKB('" + TInt.encode(GeneratedFunctions.tint_in( @@ -74,11 +71,10 @@ static void init() { } @AfterAll - static void finalizeMeos() { + static void stopSpark() { if (spark != null) { spark.stop(); } - GeneratedFunctions.meos_finalize(); } private static Object scalar(String sql) { diff --git a/src/test/java/org/mobilitydb/spark/SqlSurfaceOverUdfSurfaceTest.java b/src/test/java/org/mobilitydb/spark/SqlSurfaceOverUdfSurfaceTest.java index 238d2b64..e4de55b2 100644 --- a/src/test/java/org/mobilitydb/spark/SqlSurfaceOverUdfSurfaceTest.java +++ b/src/test/java/org/mobilitydb/spark/SqlSurfaceOverUdfSurfaceTest.java @@ -49,9 +49,6 @@ class SqlSurfaceOverUdfSurfaceTest { @BeforeAll static void init() { - // No-op error handler so a parse error returns rather than terminating the JVM. - GeneratedFunctions.meos_initialize_error_handler((level, code, message) -> { }); - GeneratedFunctions.meos_initialize(); trip = "tgeompointFromHexEWKB('" + TGeomPoint.encode(GeneratedFunctions.tgeompoint_in( "[Point(1 1)@2020-01-01 00:00:00+00, Point(2 2)@2020-01-02 00:00:00+00]")) + "')"; spark = SparkSession.builder().appName("sql-over-udf-surface").master("local[1]") @@ -64,11 +61,10 @@ static void init() { } @AfterAll - static void finalizeMeos() { + static void stopSpark() { if (spark != null) { spark.stop(); } - GeneratedFunctions.meos_finalize(); } private static Object scalar(String sql) {