New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] DeltaTableBuilder.execute() sometimes throws "Could not find active SparkSession" #1475
Comments
Good catch. Yep we should just use the By the way, do you know why active SparkSession is not available in your tests? |
No, I don't. It's very weird, when we are running the integration tests locally on our computers the tests work just fine. However, in CI (we're using Azure DevOps), the tests fail a lot, but sometimes succeed. I feel like it could be some race condition somewhere since |
Same issue during tests. Looking forward to having this fixed! |
@pgrandjean fyi Delta 2.2.0 was released which includes the fix. I upgraded the dependency and the tests now work in CI 🥳 |
awesome! thank you 👍 |
(Cherry-pick 68c8e18 to branch-2.0) Signed-off-by: Helge Bruegner <helge@bruegner.de> - Forward the SparkSession when resolving the tables in the DeltaTableBuilder - Remove some unused imports Resolves delta-io#1475 / No. Closes delta-io#1476 Signed-off-by: Shixiong Zhu <zsxwing@gmail.com> GitOrigin-RevId: 880de0f55ee79289cecd19d74c4c177c76d30aeb
(Cherry-pick 68c8e18 to branch-2.0) Signed-off-by: Helge Bruegner <helge@bruegner.de> - Forward the SparkSession when resolving the tables in the DeltaTableBuilder - Remove some unused imports Resolves delta-io#1475 / No. Closes delta-io#1476 Signed-off-by: Shixiong Zhu <zsxwing@gmail.com> GitOrigin-RevId: 880de0f55ee79289cecd19d74c4c177c76d30aeb
(Cherry-pick 68c8e18 to branch-2.1) Signed-off-by: Helge Bruegner <helge@bruegner.de> - Forward the SparkSession when resolving the tables in the DeltaTableBuilder - Remove some unused imports Resolves #1475 / No. Closes #1476 Signed-off-by: Shixiong Zhu <zsxwing@gmail.com> GitOrigin-RevId: 880de0f55ee79289cecd19d74c4c177c76d30aeb
Bug
Describe the problem
Steps to reproduce
Observed results
We are running some integration tests of our Spark jobs against some Delta tables which are created locally, on the fly, in the integration tests. The tables are stored on disk. The code above shows a (simplified) snippet of how we setup the Delta tables on disk for testing.
While running those test we sometimes (not always) observe that calling
DeltaTableBuilder.execute()
for the Delta table that we create in the tests sometimes throws an exception:org.apache.spark.sql.delta.DeltaIllegalArgumentException: Could not find active SparkSession
.This happens despite us passing the SparkSession into the
DeltaTable.create(spark)
method.Expected results
If a SparkSession is passed into
DeltaTable.create(spark)
, the exception I described above should never be thrown, since an active session exists and has been passed into the builder.Further details
Stack trace:
From the stack trace we can see that the problem is here:
delta/core/src/main/scala/io/delta/tables/DeltaTableBuilder.scala
Lines 367 to 371 in 2041c3b
A possible solution could be to always forward the SparkSession object that is present in the DeltaTableBuilder to
DeltaTable.forPath()
andDeltaTable.forName()
- they both have an optional parameter that we could use. Maybe it could be changed to something like this:Environment information
Willingness to contribute
The Delta Lake Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the Delta Lake code base?
The text was updated successfully, but these errors were encountered: