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

feat: Improved error message DSL -> IR resolving #19032

Merged
merged 1 commit into from
Sep 30, 2024
Merged

feat: Improved error message DSL -> IR resolving #19032

merged 1 commit into from
Sep 30, 2024

Conversation

ritchie46
Copy link
Member

Debugging LazyFrames can be tedious as it is unclear where the error of query originated.

Until this day. :)

We can show the resolved plan up until that failed node. That should give users information on where to look for their invalid query/bug.

q = pl.LazyFrame({"A": [0, 1, 0], "B": [1, 0, 1], "C": [1, 2, 3], "D": [4, 5, 6]})
(
 q.with_columns(pl.col("A") * 10)
 .join(q, on="A")
 .join(q, on="A")
 .select(pl.col("not-exist"))
).collect()
---------------------------------------------------------------------------
ColumnNotFoundError                       Traceback (most recent call last)
Cell In[2], line 7
      1 q = pl.LazyFrame({"A": [0, 1, 0], "B": [1, 0, 1], "C": [1, 2, 3], "D": [4, 5, 6]})
      2 (
      3  q.with_columns(pl.col("A") * 10)
      4  .join(q, on="A")
      5  .join(q, on="A")
      6  .select(pl.col("not-exist"))
----> 7 ).collect()

File ~/code/polars/py-polars/polars/lazyframe/frame.py:2050, in LazyFrame.collect(self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, cluster_with_columns, collapse_joins, no_optimization, streaming, engine, background, _eager, **_kwargs)
   2048 # Only for testing purposes
   2049 callback = _kwargs.get("post_opt_callback", callback)
-> 2050 return wrap_df(ldf.collect(callback))

ColumnNotFoundError: not-exist

Resolved plan until failure:

INNER JOIN:
LEFT PLAN ON: [col("A")]
  INNER JOIN:
  LEFT PLAN ON: [col("A")]
     WITH_COLUMNS:
     [[(col("A")) * (10)]] 
      DF ["A", "B", "C", "D"]; PROJECT */4 COLUMNS; SELECTION: None
  RIGHT PLAN ON: [col("A")]
    DF ["A", "B", "C", "D"]; PROJECT */4 COLUMNS; SELECTION: None
  END INNER JOIN
RIGHT PLAN ON: [col("A")]
  DF ["A", "B", "C", "D"]; PROJECT */4 COLUMNS; SELECTION: None
END INNER JOIN
	---> FAILED HERE RESOLVING 'select' <---

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Sep 30, 2024
@ritchie46 ritchie46 merged commit f3578c4 into main Sep 30, 2024
19 checks passed
@ritchie46 ritchie46 deleted the msg branch September 30, 2024 14:22
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 12 lines in your changes missing coverage. Please review.

Project coverage is 79.86%. Comparing base (64ca265) to head (7dd164b).
Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
...ates/polars-plan/src/plans/conversion/dsl_to_ir.rs 62.50% 12 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19032   +/-   ##
=======================================
  Coverage   79.86%   79.86%           
=======================================
  Files        1524     1524           
  Lines      207747   207767   +20     
  Branches     2908     2908           
=======================================
+ Hits       165922   165941   +19     
- Misses      41276    41277    +1     
  Partials      549      549           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@c-peters c-peters added the accepted Ready for implementation label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants