From 93f5c92ab918a6add4fd8178965a4f032704df80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=A4r?= Date: Thu, 16 Jul 2026 08:06:31 +0200 Subject: [PATCH 1/5] #43: Update version to 0.6.20. --- doc/changes/changelog.md | 1 + doc/changes/changes_0.6.20.md | 12 ++++++++++++ pk_generated_parent.pom | 2 +- pom.xml | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 doc/changes/changes_0.6.20.md diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index 3a9335b..b9d17d2 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,5 +1,6 @@ # Changes +* [0.6.20](changes_0.6.20.md) * [0.6.19](changes_0.6.19.md) * [0.6.18](changes_0.6.18.md) * [0.6.17](changes_0.6.17.md) diff --git a/doc/changes/changes_0.6.20.md b/doc/changes/changes_0.6.20.md new file mode 100644 index 0000000..8979482 --- /dev/null +++ b/doc/changes/changes_0.6.20.md @@ -0,0 +1,12 @@ +# Udf Debugging Java 0.6.20, released 2026-07-15 + +Code name: Code Coverage > 80% + +## Summary + +In this release we fixed Sonar findings and raised the code coverage ot over 80%. + +## Features + +* ISSUE_NUMBER: Fixed Sonar findings + diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index dff9fa9..d776ad2 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,7 +3,7 @@ 4.0.0 com.exasol udf-debugging-java-generated-parent - 0.6.19 + 0.6.20 pom UTF-8 diff --git a/pom.xml b/pom.xml index b88de7a..685740a 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 udf-debugging-java - 0.6.19 + 0.6.20 udf-debugging-java Utilities for debugging, profiling and code coverage measure for UDFs. https://github.com/exasol/udf-debugging-java/ @@ -147,7 +147,7 @@ udf-debugging-java-generated-parent com.exasol - 0.6.19 + 0.6.20 pk_generated_parent.pom From 86bd5e1e9ca13abff4cf571299150a24db60c8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=A4r?= Date: Thu, 16 Jul 2026 10:39:55 +0200 Subject: [PATCH 2/5] #43: Added PushDownTestingIT. --- doc/changes/changes_0.6.20.md | 5 ++ .../udfdebugging/PushDownTestingIT.java | 51 ++++++++++++++++++ src/test/resources/virtual_schema_stub.lua | 54 +++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java create mode 100644 src/test/resources/virtual_schema_stub.lua diff --git a/doc/changes/changes_0.6.20.md b/doc/changes/changes_0.6.20.md index 8979482..0148f7e 100644 --- a/doc/changes/changes_0.6.20.md +++ b/doc/changes/changes_0.6.20.md @@ -10,3 +10,8 @@ In this release we fixed Sonar findings and raised the code coverage ot over 80% * ISSUE_NUMBER: Fixed Sonar findings +## Dependency Updates + +### Plugin Dependency Updates + +* Updated `org.apache.maven.plugins:maven-jar-plugin:3.1.2` to `3.5.0` diff --git a/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java b/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java new file mode 100644 index 0000000..1816123 --- /dev/null +++ b/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java @@ -0,0 +1,51 @@ +package com.exasol.udfdebugging; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.SQLException; +import java.sql.Statement; + +import org.junit.jupiter.api.Test; + +import com.exasol.udfdebugging.modules.TestSetup; + +class PushDownTestingIT { + private static final String VS_SCHEMA = "VS_SCHEMA"; + private static final String VS_ADAPTER = VS_SCHEMA + ".VS_ADAPTER"; + private static final String VIRTUAL_SCHEMA_NAME = "TEST_VS"; + private static final String TABLE_NAME = "THE_TABLE"; + + private static String loadAdapterScriptContent() { + try { + return Files.readString(Paths.get("src/test/resources/virtual_schema_stub.lua"), StandardCharsets.UTF_8); + } catch (IOException exception) { + throw new AssertionError("Failed to read adapter script file.", exception); + } + } + + + @Test + void testGetPushDownSqlFromExplainVirtual() throws SQLException { + try ( + final TestSetup testSetup = new TestSetup(); + final Statement statement = testSetup.getConnection().createStatement() + ) { + createVirtualSchema(statement); + final String pushDownSql = PushDownTesting.getPushDownSql(statement, + "SELECT THE_VALUE FROM " + VIRTUAL_SCHEMA_NAME + "." + TABLE_NAME); + assertThat(pushDownSql, equalTo("SELECT 'Hello VS!'")); + } + } + + private void createVirtualSchema(final Statement statement) throws SQLException { + statement.execute("DROP SCHEMA IF EXISTS " + VS_SCHEMA + "CASCADE"); + statement.execute("CREATE SCHEMA " + VS_SCHEMA); + statement.execute("CREATE LUA ADAPTER SCRIPT " + VS_ADAPTER + " AS\n" + loadAdapterScriptContent() + "\n/"); + statement.execute("CREATE VIRTUAL SCHEMA " + VIRTUAL_SCHEMA_NAME + " USING " + VS_ADAPTER); + } +} diff --git a/src/test/resources/virtual_schema_stub.lua b/src/test/resources/virtual_schema_stub.lua new file mode 100644 index 0000000..7e3501b --- /dev/null +++ b/src/test/resources/virtual_schema_stub.lua @@ -0,0 +1,54 @@ +-- A minimal Lua virtual schema that allows testing VS interaction. +local cjson = require("cjson"); + +function report_schema() + return { + schemaMetadata = { + tables = { + { + name = "THE_TABLE", + columns = { + { + name = "THE_VALUE", + dataType = { + type = "CHAR", + size = 9 + } + } + } + } + } + } + } +end + +function report_capabilities() + return { + capabilities = { "SELECTLIST_PROJECTION" } + } +end + +function pushdown() + return { + type = "select", + sql = "SELECT 'Hello VS!'" + } +end + +function adapter_call(request_as_json) + local request = cjson.decode(request_as_json) + local response; + if request.type == "createVirtualSchema" or request.type == "refresh" then + response = report_schema() + elseif request.type == "dropVirtualSchema" or request.type == "setProperties" then + response = {} + elseif request.type == "getCapabilities" then + response = report_capabilities() + elseif request.type == "pushdown" then + response = pushdown() + else + error("Unsupported adapter request: " .. (request.type or "'nil'")) + end + response.type = request.type + return cjson.encode(response) +end \ No newline at end of file From a1ffd4c93c143e4b3f29d4554bbc416a092129ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=A4r?= Date: Thu, 16 Jul 2026 11:24:06 +0200 Subject: [PATCH 3/5] #43: Added test for getting the where clause. --- doc/changes/changes_0.6.20.md | 8 +++++--- .../com/exasol/udfdebugging/PushDownTesting.java | 6 ++++-- .../exasol/udfdebugging/PushDownTestingIT.java | 15 +++++++++++++++ src/test/resources/virtual_schema_stub.lua | 13 ++++++++++--- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/doc/changes/changes_0.6.20.md b/doc/changes/changes_0.6.20.md index 0148f7e..2504bbf 100644 --- a/doc/changes/changes_0.6.20.md +++ b/doc/changes/changes_0.6.20.md @@ -1,14 +1,16 @@ -# Udf Debugging Java 0.6.20, released 2026-07-15 +# Udf Debugging Java 0.6.20, released 2026-07-16 Code name: Code Coverage > 80% ## Summary -In this release we fixed Sonar findings and raised the code coverage ot over 80%. +In this release we fixed Sonar findings and raised the code coverage ot over 80%. + +We added an integration test for `PushDownTesting`. ## Features -* ISSUE_NUMBER: Fixed Sonar findings +* Fixed Sonar findings and raised test coverage. (PR #86) ## Dependency Updates diff --git a/src/main/java/com/exasol/udfdebugging/PushDownTesting.java b/src/main/java/com/exasol/udfdebugging/PushDownTesting.java index f09f147..724b132 100644 --- a/src/main/java/com/exasol/udfdebugging/PushDownTesting.java +++ b/src/main/java/com/exasol/udfdebugging/PushDownTesting.java @@ -21,9 +21,10 @@ private PushDownTesting() { * @return generated push down query * @throws SQLException if execution fails */ + @SuppressWarnings("java:S2077") // Constructed SQL only used in tests. public static String getPushDownSql(final Statement statement, final String query) throws SQLException { try (final ResultSet pushDownSqlResult = statement - .executeQuery("SELECT PUSHDOWN_SQL FROM (EXPLAIN VIRTUAL " + query + ");")) { + .executeQuery("SELECT PUSHDOWN_SQL FROM (EXPLAIN VIRTUAL " + query + ")")) { pushDownSqlResult.next(); return pushDownSqlResult.getString("PUSHDOWN_SQL"); } @@ -37,10 +38,11 @@ public static String getPushDownSql(final Statement statement, final String quer * @return selection (where clause) * @throws SQLException if SQL statement fails */ + @SuppressWarnings("java:S2077") // Constructed SQL only used in tests. public static String getSelectionThatIsSentToTheAdapter(final Statement statement, final String query) throws SQLException { try (final ResultSet pushDownSqlResult = statement - .executeQuery("SELECT PUSHDOWN_JSON FROM (EXPLAIN VIRTUAL " + query + ");")) { + .executeQuery("SELECT PUSHDOWN_JSON FROM (EXPLAIN VIRTUAL " + query + ")")) { pushDownSqlResult.next(); final String pushdownJson = pushDownSqlResult.getString("PUSHDOWN_JSON"); try (final JsonReader reader = Json.createReader(new StringReader(pushdownJson))) { diff --git a/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java b/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java index 1816123..d1aef5a 100644 --- a/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java +++ b/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java @@ -42,9 +42,24 @@ void testGetPushDownSqlFromExplainVirtual() throws SQLException { } } + @Test + void testGetSelectionThatIsSentToTheAdapter() throws SQLException { + try ( + final TestSetup testSetup = new TestSetup(); + final Statement statement = testSetup.getConnection().createStatement() + ) { + createVirtualSchema(statement); + final String pushDownSql = PushDownTesting.getSelectionThatIsSentToTheAdapter(statement, + "SELECT THE_VALUE FROM " + VIRTUAL_SCHEMA_NAME + "." + TABLE_NAME + + " WHERE THE_VALUE = 'something'"); + assertThat(pushDownSql, equalTo(TABLE_NAME +".THE_VALUE='something'")); + } + } + private void createVirtualSchema(final Statement statement) throws SQLException { statement.execute("DROP SCHEMA IF EXISTS " + VS_SCHEMA + "CASCADE"); statement.execute("CREATE SCHEMA " + VS_SCHEMA); + statement.execute("CREATE TABLE ORIGIN_TABLE(THE_VALUE CHAR(9))"); statement.execute("CREATE LUA ADAPTER SCRIPT " + VS_ADAPTER + " AS\n" + loadAdapterScriptContent() + "\n/"); statement.execute("CREATE VIRTUAL SCHEMA " + VIRTUAL_SCHEMA_NAME + " USING " + VS_ADAPTER); } diff --git a/src/test/resources/virtual_schema_stub.lua b/src/test/resources/virtual_schema_stub.lua index 7e3501b..5d62432 100644 --- a/src/test/resources/virtual_schema_stub.lua +++ b/src/test/resources/virtual_schema_stub.lua @@ -24,15 +24,22 @@ end function report_capabilities() return { - capabilities = { "SELECTLIST_PROJECTION" } + capabilities = { "SELECTLIST_PROJECTION", "FILTER_EXPRESSIONS", "FN_PRED_EQUAL", "LITERAL_STRING" } } end -function pushdown() +function pushdown(request) + if (request.filter == nil) then return { type = "select", sql = "SELECT 'Hello VS!'" } + else + return { + type = "select", + sql = "SELECT 'Hello VS!' FROM VS_SCHEMA.ORIGIN_TABLE WHERE THE_VALUE = 'something'" + } + end end function adapter_call(request_as_json) @@ -45,7 +52,7 @@ function adapter_call(request_as_json) elseif request.type == "getCapabilities" then response = report_capabilities() elseif request.type == "pushdown" then - response = pushdown() + response = pushdown(request.pushdownRequest) else error("Unsupported adapter request: " .. (request.type or "'nil'")) end From 812e43d13f8ffb60ebebc91ad6293ca9f92c78ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=A4r?= Date: Thu, 16 Jul 2026 11:28:50 +0200 Subject: [PATCH 4/5] #43: Fixed changelog. --- doc/changes/changes_0.6.20.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/changes/changes_0.6.20.md b/doc/changes/changes_0.6.20.md index 2504bbf..42b191f 100644 --- a/doc/changes/changes_0.6.20.md +++ b/doc/changes/changes_0.6.20.md @@ -12,8 +12,3 @@ We added an integration test for `PushDownTesting`. * Fixed Sonar findings and raised test coverage. (PR #86) -## Dependency Updates - -### Plugin Dependency Updates - -* Updated `org.apache.maven.plugins:maven-jar-plugin:3.1.2` to `3.5.0` From 55264710108dd9bf2dd5a6e60b1ad76c61100234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=A4r?= Date: Thu, 16 Jul 2026 14:22:07 +0200 Subject: [PATCH 5/5] #43: Taking the Lua VS from the classpath.. --- .../com/exasol/udfdebugging/PushDownTestingIT.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java b/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java index d1aef5a..834c65c 100644 --- a/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java +++ b/src/test/java/com/exasol/udfdebugging/PushDownTestingIT.java @@ -4,9 +4,8 @@ import static org.hamcrest.Matchers.equalTo; import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; import java.sql.SQLException; import java.sql.Statement; @@ -21,10 +20,14 @@ class PushDownTestingIT { private static final String TABLE_NAME = "THE_TABLE"; private static String loadAdapterScriptContent() { - try { - return Files.readString(Paths.get("src/test/resources/virtual_schema_stub.lua"), StandardCharsets.UTF_8); + try (InputStream adapterScriptStream = PushDownTestingIT.class.getClassLoader() + .getResourceAsStream("virtual_schema_stub.lua")) { + if (adapterScriptStream == null) { + throw new AssertionError("Failed to find adapter script resource on the classpath."); + } + return new String(adapterScriptStream.readAllBytes(), StandardCharsets.UTF_8); } catch (IOException exception) { - throw new AssertionError("Failed to read adapter script file.", exception); + throw new AssertionError("Failed to read adapter script resource.", exception); } }