ā07-10-2023 07:45 AM
Hi Everyone,
I am trying to get spark context by running SparkSession builder command in a .py file and when i try to run it directl it works but if i got to a notebook and in a cell if i use %sh command to run python "myfilename" it gives an error that i am trying to create a new session. How to solve this?
Any help would be appreciated.
Thanks
ā07-10-2023 07:53 AM
Hi @deficiant_codge, Databricks already provide variables for sparksession and sparkcontext.
Use spark for sparksession and sc for sparkcontext.
I think this would help you.
ā07-10-2023 08:11 AM
Actually i have some use case in which i have to mandatorily run the python file using %sh and in that i can't able to access those variables. I am aware of these variables but the problem is they just don't work.
see the below images:
ā07-10-2023 08:42 AM
@deficiant_codge Can you try with below:
ā07-10-2023 08:44 AM - edited ā07-10-2023 08:44 AM
I tried it also attached the image attached with the post, but it didn't worked
ā07-10-2023 08:45 AM
ā07-10-2023 10:04 AM
No Success š
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonāt want to miss the chance to attend and share knowledge.
If there isnāt a group near you, start one and help create a community that brings people together.
Request a New Group