I am just trying to load data from a Snowflake table as below (with Spark/Scala in Databricks env) :
def loadDataFromSnowFlake(SfOptions: Map[String, String], query: String): DataFrame =
spark.read
.format("net.snowflake.spark.snowflake")
.options(SfOptions)
.option("query", query)
.load()
}
val SfOptions = ???
val query = "SELECT * FROM databaseName.public.tableName LIMIT 10"
val testDf = loadDataFromSnowFlake(SfOptions, query)
testDf.show()
testDf.show()
The thing is that the two show() at the end of my script sent me back two different results, and I do not understand how it is possible when my dataframe testDf is declared as immutable.
I would appreciate a clarification on that. Thanks a lot. Cheers
show()
does nothing more than triggering an action which will send the query to the Snowflake database. Without any ordering there is no guarantee thatlimit 10
will return the same 10 result – UninformedUser