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
    .option("dbtable", "EMPLOYEE")

Naveen Nelamali

Naveen Nelamali (NNK) is a Data Engineer with 20+ years of experience in transforming data into actionable insights. Over the years, He has honed his expertise in designing, implementing, and maintaining data pipelines with frameworks like Apache Spark, PySpark, Pandas, R, Hive and Machine Learning. Naveen journey in the field of data engineering has been a continuous learning, innovation, and a strong commitment to data integrity. In this blog, he shares his experiences with the data as he come across. Follow Naveen @ LinkedIn and Medium