Update connection configuration reference¶

Database objects and procedures¶

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

PUBLIC.UPDATE_CONNECTION_CONFIGURATION( connection_configuration VARIANT)¶

Entry point procedure available to the ADMIN role. This procedure invokes the Java UpdateConnectionConfigurationHandler.updateConnectionConfiguration handler.

PUBLIC.UPDATE_CONNECTION_CONFIGURATION_VALIDATE( connection_configuration VARIANT)¶

Procedure used for providing additional connector specific validation logic. By default, it returns 'response_code': 'OK'. It is invoked by the default ConnectionConfigurationInputValidator. Can be overwritten both in SQL and Java.

PUBLIC.DRAFT_CONNECTION_CONFIGURATION_INTERNAL( connection_configuration VARIANT)¶

Procedure used for providing additional connector specific logic. By default, it returns 'response_code': 'OK'. It is invoked by the default ConnectionConfigurationCallback. Can be overwritten both in SQL and Java.

Custom handler¶

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 a custom implementation of UpdateConnectionConfigurationHandler the PUBLIC.UPDATE_CONNECTION_CONFIGURATION procedure must be replaced. For example:

CREATE OR REPLACE PROCEDURE PUBLIC.UPDATE_CONNECTION_CONFIGURATION(connection_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.CustomUpdateConnectionConfigurationHandler.updateConnectionConfiguration';

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

Internal procedures¶

The VALIDATE and INTERNAL procedures can also be customized through SQL. It can even invoke another Java handler:

CREATE OR REPLACE PROCEDURE PUBLIC.DRAFT_CONNECTION_CONFIGURATION_INTERNAL(connection_configuration 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.UPDATE_CONNECTION_CONFIGURATION_VALIDATE(connection_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.CustomConnectionConfigurationInputValidator.validate';
Copy

Builder approach¶

UpdateConnectionConfigurationHandler can be customized using UpdateConnectionConfigurationHandlerBuilder. This builder allows the developer to provide custom implementations of the following interfaces:

  • ConnectionConfigurationInputValidator

  • ConnectionConfigurationCallback

  • DraftConnectionValidator

  • ConnectionConfigurationCallback

  • ConnectionValidator

  • ConnectorErrorHelper

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

class CustomConnectionConfigurationInputValidator implements ConnectionConfigurationInputValidator {

    @Override
    public ConnectorResponse validate(Variant configuration) {
        // CUSTOM VALIDATION LOGIC
        return ConnectorResponse.success();
    }
}

class CustomHandler {

    // Path to this method needs to be specified in the PUBLIC.UPDATE_CONNECTION_CONFIGURATION procedure using SQL
    public static Variant updateConnectionConfiguration(Session session, Variant configuration) {
        // Using the builder
        var handler = UpdateConnectionConfigurationHandler.builder(session)
            .withInputValidator(new CustomConnectionConfigurationInputValidator())
            .build();
        return handler.updateConnectionConfiguration(configuration).toVariant();
    }
}
Copy