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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

1011 Running sql using sparkconnect should not print full stack trace #1012

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

b1ackout
Copy link

@b1ackout b1ackout commented May 10, 2024

Describe your changes

  1. Added try catch on handle_spark_dataframe. When pyspark.sql.utils.AnalysisException occurs, it shows only the spark error and not the full stack trace

Issue number

Closes #1011

Checklist before requesting a review


馃摎 Documentation preview 馃摎: https://jupysql--1012.org.readthedocs.build/en/1012/

@b1ackout b1ackout requested a review from edublancas as a code owner May 10, 2024 10:16
raise exceptions.MissingPackageError("pysark not installed")

return SparkResultProxy(dataframe, dataframe.columns, should_cache)
try:

Choose a reason for hiding this comment

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

please integrate this with short_errors:

short_errors = Bool(

by default, it should raise the exception, if short_errors is True, then just print it

return SparkResultProxy(dataframe, dataframe.columns, should_cache)
try:
return SparkResultProxy(dataframe, dataframe.columns, should_cache)
except AnalysisException as e:

Choose a reason for hiding this comment

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

this except is redundant, the except Exception as e can catch all exceptions

@edublancas edublancas added the feature Adds a new feature label May 21, 2024
@b1ackout b1ackout marked this pull request as draft May 23, 2024 07:34
@@ -559,6 +559,7 @@ def is_non_sqlalchemy_error(error):
# Pyspark
"UNRESOLVED_ROUTINE",
"PARSE_SYNTAX_ERROR",
"AnalysisException",
Copy link
Author

Choose a reason for hiding this comment

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

After looking through the code I think adding AnalysisException here will solve the issue since PARSE_SYNTAX_ERROR works as expected.
AnalysisException covers all these error conditions.

Copy link
Author

Choose a reason for hiding this comment

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

I just need to test it somehow. Will try to package the jupysql and install it in a spark environment

Choose a reason for hiding this comment

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

you can install like this:

pip install git+https://github.com/b1ackout/jupysql@running-sql-using-sparkconnect-should-not-print-full-stack-trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants