Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions python/pyspark/errors/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ def _capture_call_site(
in the user code that led to the error.
"""
stack = list(reversed(inspect.stack()))

# We try import here since IPython is not a required dependency
try:
from IPython import get_ipython

if get_ipython():
import pyspark

# Filtering out PySpark code and keeping user code only
pyspark_root = os.path.dirname(pyspark.__file__)
stack = [
frame_info
for frame_info in inspect.stack()
if pyspark_root not in frame_info.filename
]
except ImportError:
pass

depth = int(
spark_session.conf.get("spark.sql.stackTracesInDataFrameContext") # type: ignore[arg-type]
)
Expand Down