cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Snowflake connection to databricks error

shivank25
New Contributor II

I am trying to connect to snowflake using data bricks but getting the below error

net.snowflake.client.jdbc.SnowflakeSQLException: JDBC driver encountered a communication error. Message: Exception encountered for HTTP request: Connect to xxx.region.snowflakecomputing.com:443 [XXX.region.snowflakecomputing.com/, XXX.region.snowflakecomputing.com/] failed: Read timed out.

 

user = dbutils.secrets.get("data-warehouse", "snowflake-user")
password = dbutils.secrets.get("data-warehouse", "snowflake-password")
SNOWFLAKE_SOURCE_NAME = "net.snowflake.spark.snowflake"
options = {
"sfUrl": "xxx.snowflakecomputing.com",
"sfUser": user,
"sfPassword": password,
"sfDatabase": "DB",
"sfSchema": "schema",
"sfWarehouse": "wharehouse"
}

snowflake_df = spark.read \
.format(SNOWFLAKE_SOURCE_NAME) \
.options(**options) \
.option("dbtable", "table") \
.load()

display(snowflake_df)
 
can you please let me know if I am missing something?

 

 

 

 

3 REPLIES 3

Priyanka_Biswas
Valued Contributor

Hello @shivank25Databricks provides a Snowflake connector in the Databricks Runtime to support reading and writing data from Snowflake. 

Could you please try with below code and let me know if it works for you ?

snowflake_table = (spark.read
.format("snowflake")
.option("dbtable", table_name)
.option("sfUrl", database_host_url)
.option("sfUser", username)
.option("sfPassword", password)
.option("sfDatabase", database_name)
.option("sfSchema", schema_name)
.option("sfWarehouse", warehouse_name)
.load()

#Use snowflake connector 

df = spark.read \
.format("snowflake") \
.options(options) \
.option("dbtable", "table_name") \
.load()
display(df)

Ref: https://docs.databricks.com/external-data/snowflake.html

Thanks for your response @Priyanka_Biswas .

I am getting the below error now 

net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:
--------------------------------------------------------------------------- Py4JJavaError Traceback (most recent call last) File <command-4201251452332141>:1 ----> 1 snowflake_table = (spark.read 2 .format("snowflake")

Anonymous
Not applicable

Hi @shivank25 

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance! 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group