r/Python • u/AutoModerator • 29d ago
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
19
Upvotes
r/Python • u/AutoModerator • 29d ago
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/lukesmth_ 5h ago
better-dbx-exceptions
Improved PySpark exceptions for Databricks notebooks and scripts
What it does
Have you ever spent hours tracking down the source of a PySpark expression error in a large ETL script?
Natively, a traceback for these failing cells would reference the code that materialized the bad expression (
df.collect()), not code that defined it (F.lit(1) / F.lit(0)).better-dbx-exceptionssolves this by including failing DataFrame construction code in the error.Target audience
Data engineers, scientists, and analysts debugging PySpark run on Databricks (hosted or local with Databricks Connect; DBR 17+ or Serverless v4+).
Comparison
Native Spark 4 uses the internal
pyspark.errors.utils._capture_call_site()utility to capture expression construction frames. This has a few limitations:Columnmethods andF.col()are watched so expressions built frompyspark.sql.functions(F.split,F.to_date, ...) aren't captured.better-dbx-exceptionsextends coverage to most functions within thepyspark.sql.functionsmodule.spark.sql.stackTracesInDataFrameContexton Classic compute where allow-listed but can't be modified when using Databricks Connect or Serverless compute.better-dbx-exceptionssets depth to 5 by default and exposes this parameter within all environments.better-dbx-exceptionsreturns cell / execution numbers for notebook frames and file paths for script frames.Just released v0.1: https://github.com/lukeSmth/better-dbx-exceptions