Connection configuration reference¶

Database objects and procedures¶

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

PUBLIC.SET_CONNECTION_CONFIGURATION (connection_configuration VARIANT)¶

Entry point procedure available to ADMIN role. This procedure invokes the Java function ConnectionConfigurationHandler.setConnectionConfiguration().

PUBLIC.SET_CONNECTION_CONFIGURATION_VALIDATE (connection_configuration VARIANT)¶

Procedure used for Connector specific validation of the configuration. It can also be used to transform some parts of the configuration. Transformed configuration needs to be returned as additional "config" property. By default, it returns 'response_code': 'OK'. It is invoked by the DefaultConnectionConfigurationInputValidator. Can be overwritten both in SQL and Java.

PUBLIC.SET_CONNECTION_CONFIGURATION_INTERNAL (connection_configuration VARIANT)¶

Procedure used for Connector specific additional connection configuration, for example adding external access integration to other procedures. By default, it returns 'response_code': 'OK'. It is invoked by the InternalConnectionConfigurationCallback. Can be overwritten both in SQL and Java.

PUBLIC.GET_CONNECTION_CONFIGURATION()¶

A procedure to retrieve current connection configuration from the internal table. It is available to ADMIN and VIEWER users.

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 whole custom implementation of the ConnectionConfigurationHandler the PUBLIC.SET_CONNECTION_CONFIGURATION procedure must be replaced. For example:

CREATE OR REPLACE PROCEDURE PUBLIC.SET_CONNECTION_CONFIGURATION(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.CustomConnectionConfigurationHandler.setConnectionConfiguration';

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

Internal procedures¶

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

CREATE OR REPLACE PROCEDURE PUBLIC.SET_CONNECTION_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', '"config"', '"transformed config variant"');
END;

CREATE OR REPLACE PROCEDURE PUBLIC.SET_CONNECTION_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.CustomConnectionConfigurationValidateHandler.setConnectionConfiguration';
Copy

Builder approach¶

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

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 config) {
        // CUSTOM LOGIC
        return ConnectorResponse.success();
    }
}

class CustomHandler {

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