2
votes

I have 2 questions w.r.t spark and Snowflake datawarehouse.

1) Is there any way to query/create snowflake tables like hive/spark(either new or old versions of spark)

val hive_tables=hiveContext.sql("show tables").foreach(println)

2) hiveContext.sql("create table....")

first question is about knowing what tables are present for that particular user for the particular role. The reason why I am asking question is via web ui of snowflake I am able to query the table but through spark I am not able to query

Exception in thread "main" net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:
Object 'mytable' does not exist.
1

1 Answers

2
votes

You should double check things like database/schema/role in your JDBC connection settings. If you don't see a table via JDBC, one of these might be the culprit.

You can validate the current settings by running e.g. show roles, show schemas and show databases on the established JDBC connection.

In general, I highly recommend using Spark-Snowflake connector for communicating with Snowflake from Spark. It also provides Utils.runQuery() for running simple queries like DDL.