exasol / exasol-virtual-schema

Virtual Schema from Exasol to Exasol
MIT License
1 stars 2 forks source link

Inconsistent check of EXA_CONNECTION #90

Closed exaSR closed 1 year ago

exaSR commented 1 year ago

Original report

Adapter Version virtual-schema-dist-10.1.0-exasol-7.0.2

Semantic check for EXA_CONNECTION parameter is active for CREATE:

CREATE VIRTUAL SCHEMA CDP4_CDP
USING VSA.EXASOL_ADAPTER WITH
    CONNECTION_NAME = 'CDP_JDBC'
    SCHEMA_NAME     = 'CDP'
    EXA_CONNECTION  = Null
;

yields error message

[Code: 0, SQL State: 42000] Value of property EXA_CONNECTION must not be null or empty. [line 5, column 27] (Session: 1758344366162313216) [Script position: 4835 - 4836]

But not for ALTER:

CREATE VIRTUAL SCHEMA CDP4_CDP
USING VSA.EXASOL_ADAPTER WITH
    CONNECTION_NAME = 'CDP_JDBC'
    SCHEMA_NAME     = 'CDP'
    IMPORT_FROM_EXA = 'true'
    EXA_CONNECTION  = 'Beep'
;
-- takes a few seconds

select count(*) from cdp4_cdp.account_sf;
-- fails with 'BEEP' does not exist -- ok.

alter virtual schema CDP4_CDP set EXA_CONNECTION = Null;
-- is accepted

select count(*) from cdp4_cdp.account_sf;

-->

[Code: 0, SQL State: 22002]  VM error: F-UDF-CL-LIB-1126: F-UDF-CL-SL-JAVA-1006: F-UDF-CL-SL-JAVA-1026: 
com.exasol.ExaUDFException: F-UDF-CL-SL-JAVA-1068: Exception during singleCall adapterCall 
java.lang.IllegalArgumentException: E-VSEXA-1: Incomplete remote connection information Please specify a named EXA connection 'EXA_CONNECTION' for the ExaLoader and a named JDBC connection with 'CONNECTION_NAME' for the Virtual Schema adapter.
com.exasol.adapter.dialects.exasol.ExasolConnectionDefinitionBuilder.buildImportFromExaConnectionDefinition(ExasolConnectionDefinitionBuilder.java:40)
com.exasol.adapter.dialects.exasol.ExasolConnectionDefinitionBuilder.buildConnectionDefinition(ExasolConnectionDefinitionBuilder.java:23)
com.exasol.adapter.dialects.rewriting.AbstractQueryRewriter.rewrite(AbstractQueryRewriter.java:49)
com.exasol.adapter.dialects.AbstractSqlDialect.rewriteQuery(AbstractSqlDialect.java:141)
com.exasol.adapter.jdbc.JDBCAdapter.pushdown(JDBCAdapter.java:243)
com.exasol.adapter.AdapterCallExecutor.executePushDownRequest(AdapterCallExecutor.java:117)
com.exasol.adapter.request.PushDownRequest.executeWith(PushDownRequest.java:66)
com.exasol.adapter.AdapterCallExecutor.executeAdapterCall(AdapterCallExecutor.java:34)
com.exasol.adapter.RequestDispatcher.processAdapterCall(RequestDispatcher.java:55)
com.exasol.adapter.RequestDispatcher.adapterCall(RequestDispatcher.java:33)
com.exasol.ExaWrapper.runSingleCall(ExaWrapper.java:101)
 (Session: 1758344366162313216)

(related with #89: once IMPORT_FROM_EXA is set, it can not be disabled)

ckunki commented 1 year ago

I think the changes with VSEXA 7.1.0 and VSCJDBC 10.3.0 already fixed this problem. In the scope of the current ticket I will add an additional integration test, though:

    @Test
    void testAlterVirtualSchemaTriggersPropertyValidation() throws SQLException {
        this.virtualSchema = createVirtualSchema(this.sourceSchema);
        final String name = this.virtualSchema.getFullyQualifiedName();
        final SQLException exception = assertThrows(SQLException.class,
                () -> query("alter virtual schema {0} set EXA_CONNECTION = Null", name));
        final String expected = PropertyValidationException.class.getName() + ": E-VSCJDBC-17";
        assertThat(exception.getMessage(), containsString(expected));
    }