Skip to content

Conversation

@b1ackout
Copy link

@b1ackout b1ackout commented Sep 2, 2024

Describe your changes

  1. Updated is_non_sqlalchemy_error to handle pyspark.sql.utils.AnalysisException, thus when short_errors is enabled to show only the spark sql error and not the full stack trace

Issue number

Closes #1011

Checklist before requesting a review


📚 Documentation preview 📚: https://jupysql--1024.org.readthedocs.build/en/1024/

@b1ackout b1ackout requested a review from edublancas as a code owner September 2, 2024 10:56
Comment on lines +566 to +572
is_pyspark_analysis_exception = (
isinstance(error, AnalysisException) if AnalysisException else False
)
return (
any(msg in str(error) for msg in specific_db_errors)
or is_pyspark_analysis_exception
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If AnalysisException is imported then checks if the error is of instance of pyspark's Analysis Exception and handles it accordingly

Comment on lines +11 to +15
try:
from pyspark.sql.utils import AnalysisException
except ModuleNotFoundError:
AnalysisException = None

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to handle the case where pyspark module is not installed


def handle_spark_dataframe(dataframe, should_cache=False):
"""Execute a ResultSet sqlaproxy using pysark module."""
"""Execute a ResultSet sqlaproxy using pyspark module."""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo

"""Execute a ResultSet sqlaproxy using pyspark module."""
if not DataFrame and not CDataFrame:
raise exceptions.MissingPackageError("pysark not installed")
raise exceptions.MissingPackageError("pyspark not installed")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo

Comment on lines -559 to -561
# Pyspark
"UNRESOLVED_ROUTINE",
"PARSE_SYNTAX_ERROR",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed these as they are included in AnalysisException

@b1ackout
Copy link
Author

b1ackout commented Jan 8, 2025

@edublancas happy new year!
Can you review the PR?

@edublancas edublancas merged commit e073f7b into ploomber:master Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants