Skip to content
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

RecursionError: maximum recursion depth exceeded while calling a Python object #236

Open
educhana opened this issue Jan 8, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@educhana
Copy link

educhana commented Jan 8, 2025

Hi,

I've a problem using the spark backend when using an already created SparkSession. This is the simplest code to reproduce:

from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()

from sqlframe import activate
activate(engine="spark", conn=spark)


from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()

# Traceback on last getOrCreate:
# 
#   .........
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 121, in builder
#     return cls.Builder()
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 132, in __init__
#     self.builder = SparkSession.builder
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlglot\helper.py", line 44, in __get__
#     return classmethod(self.fget).__get__(None, owner)()  # type: ignore
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 121, in builder
#     return cls.Builder()
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 132, in __init__
#     self.builder = SparkSession.builder
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlglot\helper.py", line 44, in __get__
#     return classmethod(self.fget).__get__(None, owner)()  # type: ignore
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 121, in builder
#     return cls.Builder()
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 132, in __init__
#     self.builder = SparkSession.builder
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlglot\helper.py", line 44, in __get__
#     return classmethod(self.fget).__get__(None, owner)()  # type: ignore
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 121, in builder
#     return cls.Builder()
#   File "c:\ProgramData\anaconda3\envs\leanval-lib\lib\site-packages\sqlframe\spark\session.py", line 128, in __init__
#     def __init__(self):
#   File "_pydevd_bundle\\pydevd_cython.pyx", line 1697, in _pydevd_bundle.pydevd_cython.SafeCallWrapper.__call__
# RecursionError: maximum recursion depth exceeded while calling a Python object

seems that in SparkSession.builder tries to get the builder which is itself, thus the error.

Software versions:
sqlframe: 3.13.0
Any Python, tested on: >3.10
Any Spark version, tested on: >3.2

@eakmanrq
Copy link
Owner

This is going to be tricky to resolve. I need to figure out a way to replace the pyspark imports for the user's code but then still allow SQLFrame to refer to the PySpark imports when executing statements. Going to remove the activate option from Spark docs until I figure it out (changing imports still works).

@eakmanrq eakmanrq added the bug Something isn't working label Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants