Finalize configuration reference

Database objects and procedures

The following database objects are created through the file configuration/finalize_configuration.sql.

PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION (CUSTOM_CONFIGURATION VARIANT)

Entry point procedure available to the ADMIN role. This procedure invokes the Java function FinalizeConnectorHandler.finalizeConnectorConfiguration.

PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION_VALIDATE (CUSTOM_CONFIGURATION VARIANT)

Procedure used for connector specific validation of the custom configuration. By default, it returns 'response_code': 'OK'. It is invoked by DefaultFinalizeConnectorValidator. Can be overwritten both in SQL and Java.

PUBLIC.VALIDATE_SOURCE (CUSTOM_CONFIGURATION VARIANT)

Procedure checking the connection to the source system with additional configuration specific to the connector. In some cases it might be the same as the TEST_CONNECTION procedure, but sometimes it will be performing checks in a more detailed way. By default, it returns 'response_code': 'OK'. It is invoked by InternalSourceValidator.

PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION_INTERNAL (CUSTOM_CONFIGURATION VARIANT)

Procedure used to perform any additional custom configurations. By default, it returns 'response_code': 'OK'. It is invoked by InternalFinalizeConnectorCallback. Can be overwritten both in SQL and Java.

Custom handler

The handler and its internals can be customized using the following two approaches.

Procedure replacement approach

The following components can be replaced using SQL.

Handler

To provide whole custom implementation of FinalizeConnectorHandler the PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION procedure must be replaced. For example:

CREATE OR REPLACE PROCEDURE PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION(CUSTOM_CONFIGURATION VARIANT)
RETURNS VARIANT
LANGUAGE JAVA
RUNTIME_VERSION = '11'
PACKAGES = ('com.snowflake:snowpark:1.11.0')
IMPORTS = ('/connectors-native-sdk.jar')
HANDLER = 'com.custom.handler.CustomFinalizeConnectorHandler.finalizeConnectorConfiguration';

GRANT USAGE ON PROCEDURE PUBLIC.CONFIGURE_CONNECTOR(VARIANT) TO APPLICATION ROLE ADMIN;
Copy

Internal procedures

Internal VALIDATE, INTERNAL and VALIDATE_SOURCE procedures can be also customized through the SQL. They can even invoke another Java handler:

CREATE OR REPLACE PROCEDURE PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION_INTERNAL(config VARIANT)
RETURNS VARIANT
LANGUAGE SQL
EXECUTE AS OWNER
AS
BEGIN
    -- SOME CUSTOM LOGIC BEGIN
    SELECT sysdate();
    -- SOME CUSTOM LOGIC END

    RETURN OBJECT_CONSTRUCT('response_code', 'OK');
END;

CREATE OR REPLACE PROCEDURE PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION_VALIDATE (config VARIANT)
RETURNS VARIANT
LANGUAGE JAVA
RUNTIME_VERSION = '11'
PACKAGES = ('com.snowflake:snowpark:1.11.0')
IMPORTS = ('/connectors-native-sdk.jar')
HANDLER = 'com.custom.handler.CustomFinalizeConnectorConfigurationValidateHandler.validate';
Copy

Builder approach

FinalizeConnectorHandler can be customized using FinalizeConnectorHandlerBuilder. This builder allows the user to provide custom implementations of the following interfaces:

  • FinalizeConnectorValidator

  • SourceValidator

  • FinalizeConnectorCallback

  • ConnectorErrorHelper

In case one of them is not provided the default implementation provided by the SDK will be used.

class CustomFinalizeConnectorValidator implements FinalizeConnectorValidator {
    @Override
    public ConnectorResponse validate(Variant config) {
        // CUSTOM LOGIC
        return ConnectorResponse.success();
    }
}

class CustomHandler {

    // Path to this method needs to be specified in the PUBLIC.FINALIZE_CONNECTOR_CONFIGURATION procedure using SQL
    public static Variant finalizeConnector(Session session, Variant configuration) {
            //Using builder
        var handler = FinalizeConnectorHandler.builder(session)
            .withValidator(new CustomFinalizeConnectorValidator())
            .build();
        return handler.finalizeConnector(configuration).toVariant();
    }
}
Copy