SnowflakeSQLException: SQL compilation error: Object $$ does not exist or not authorized.

Spread the love

While accessing the Snowflake table from Apache Spark, getting “SnowflakeSQLException” with error message Object “table name” does not exist or not authorized.

net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:
Object ‘EMPLOYEE’ does not exist or not authorized.

Out of many, one fo the reason for this error is due to the table not having appropriate access for the user. On Snowflake console, please check the role for the selected database, schema and table individually.

And by providing "sfRole" -> "ACCOUNTADMIN" as an option, you should able to access the database and table successfully.


var sfOptions = Map(
    "sfURL" -> "https://oea81082.us-east-1.snowflakecomputing.com/",
    "sfAccount" -> "oea81082",
    "sfUser" -> "nnkumar13",
    "sfPassword" -> "Nelamalli#1",
    "sfDatabase" -> "EMP",
    "sfSchema" -> "PUBLIC",
    "sfRole" -> "ACCOUNTADMIN"
  )

  val df: DataFrame = spark.read
    .format("net.snowflake.spark.snowflake")
    .options(sfOptions)
    .option("dbtable", "EMPLOYEE")
    .load()

Naveen (NNK)

SparkByExamples.com is a Big Data and Spark examples community page, all examples are simple and easy to understand and well tested in our development environment Read more ..

Leave a Reply