0

I am trying to connect to snowflake DB and activate a particular warehouse.I have used warehouse in both JDBC connection

jdbc:snowflake://xy12345.eu-central-1.snowflakecomputing.com/?warehouse=mywh

as well as in the properties

options.put("warehouse", "mywh")

Is there anything else that needs to be added .

Even if I am giving an incorrect warehouse , the connection goes through which is not right . Am I missing anything or is there anyway to execute "use warehouse mywh" through spark .

Thanks

Ann Poh
  • 41
  • 2
  • can you add more information on logs & code? – sathya Jul 25 '20 at 17:20
  • 1
    I am not getting any issues while connecting even if I am giving an incorrect warehouse name . I am able to connect to my DB – Ann Poh Jul 25 '20 at 17:42
  • Connecting to Snowflake and using a warehouse are 2 different things. Totally possible to connect to Snowflake without a warehouse. So, are you sure that you have permissions to the warehouse that you are specifying and have no typos? If you log into the UI with that same user/role, can you select that warehouse successfully? This sounds like an RBAC issue. – Mike Walton Jul 26 '20 at 12:53

2 Answers2

0

Can you execute command - USE WAREHOUSE using cursor to change the warehouse usage.

Sriga
  • 1,165
  • 4
  • 11
0

Using the warehouse parameter on JDBC, or giving it in the properties are enough to use that warehouse. The confusion is about how JDBC driver connects to Snowflake.

When you connect to Snowflake with JDBC, JDBC driver does not run "USE WAREHOUSE" immediately. This is why you do not get any error while connecting, even you entered a wrong warehouse.

When you try to execute a SQL query, if it requires an active warehouse, the warehouse you picked will be used. In case, you entered a wrong warehouse, you get an error something like this:

Exception in thread "main" net.snowflake.client.jdbc.SnowflakeSQLException: No active warehouse selected in the current session.  Select an active warehouse with the 'use warehouse' command.
Gokhan Atil
  • 9,278
  • 2
  • 11
  • 24