Class SnowflakeClient
- java.lang.Object
-
- net.snowflake.hivemetastoreconnector.core.SnowflakeClient
-
public class SnowflakeClient extends Object
Class that uses the snowflake jdbc to connect to snowflake. Executes the commands TODO: modify exception handling
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSnowflakeClient.ThrowableSupplier<T,E extends Throwable>Helper interface that represents a Supplier that can throw an exception.
-
Constructor Summary
Constructors Constructor Description SnowflakeClient()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcreateAndExecuteCommandForSnowflake(org.apache.hadoop.hive.metastore.events.ListenerEvent event, SnowflakeConf snowflakeConf)Creates and executes an event for snowflake.static ResultSetexecuteStatement(Connection connection, String commandStr, SnowflakeConf snowflakeConf)(Deprecated) Utility method to connect to Snowflake and execute a query.static voidexecuteStatements(List<String> commandList, SnowflakeConf snowflakeConf, String schema)Helper method to connect to Snowflake and execute a list of queriesstatic voidgenerateAndExecuteSnowflakeStatements(Command command, SnowflakeConf snowflakeConf)Helper method.static ConnectiongetConnection(SnowflakeConf snowflakeConf, String schema)Get the connection to the Snowflake account.static <T,E extends Throwable>
Tretry(SnowflakeClient.ThrowableSupplier<T,E> method, SnowflakeConf snowflakeConf)Helper method for simple retries.
-
-
-
Method Detail
-
createAndExecuteCommandForSnowflake
public static void createAndExecuteCommandForSnowflake(org.apache.hadoop.hive.metastore.events.ListenerEvent event, SnowflakeConf snowflakeConf)Creates and executes an event for snowflake. Events may be processed in the background, but events on the same table will be processed in order.- Parameters:
event- - the hive event detailssnowflakeConf- - the configuration for Snowflake Hive metastore
-
generateAndExecuteSnowflakeStatements
public static void generateAndExecuteSnowflakeStatements(Command command, SnowflakeConf snowflakeConf)
Helper method. Generates commands for an event and executes those commands. Synchronous.- Parameters:
command- - the command to generate statements fromsnowflakeConf- - the configuration for Snowflake Hive metastore
-
executeStatements
public static void executeStatements(List<String> commandList, SnowflakeConf snowflakeConf, String schema)
Helper method to connect to Snowflake and execute a list of queries- Parameters:
commandList- - The list of queries to executesnowflakeConf- - the configuration for Snowflake Hive metastore listenerschema- - the schema to use for the jdbc connection
-
executeStatement
public static ResultSet executeStatement(Connection connection, String commandStr, SnowflakeConf snowflakeConf) throws SQLException
(Deprecated) Utility method to connect to Snowflake and execute a query.- Parameters:
connection- - The connection to usecommandStr- - The query to executesnowflakeConf- - the configuration for Snowflake Hive metastore listener- Returns:
- The result of the executed query
- Throws:
SQLException- Thrown if there was an error executing the statement or forming a connection.
-
getConnection
public static Connection getConnection(SnowflakeConf snowflakeConf, String schema) throws SQLException
Get the connection to the Snowflake account. First finds a Snowflake driver and connects to Snowflake using the given properties.- Parameters:
snowflakeConf- - the configuration for Snowflake Hive metastore listenerschema- - the schema to use for the connection- Returns:
- The JDBC connection
- Throws:
SQLException- Exception thrown when initializing the connection
-
retry
public static <T,E extends Throwable> T retry(SnowflakeClient.ThrowableSupplier<T,E> method, SnowflakeConf snowflakeConf) throws E extends Throwable
Helper method for simple retries. Overload for default arguments.- Type Parameters:
T- The type of object returned by the supplierE- The type of exception thrown by the supplier- Parameters:
method- The method to be executed and retried on.snowflakeConf- The snowflake configuration to use.- Returns:
- The result of the method.
- Throws:
E extends Throwable
-
-