Skip to content

Commit

Permalink
Add test example for backtraces (#10143)
Browse files Browse the repository at this point in the history
  • Loading branch information
comphead committed Apr 22, 2024
1 parent 77f43c5 commit 0b5bfe2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/source/user-guide/example-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,28 @@ backtrace: 0: std::backtrace_rs::backtrace::libunwind::trace
............
```
The backtraces are useful when debugging code. If there is a test in `datafusion/core/src/physical_planner.rs`
```
#[tokio::test]
async fn test_get_backtrace_for_failed_code() -> Result<()> {
let ctx = SessionContext::new();

let sql = "
select row_numer() over (partition by a order by a) from (select 1 a);
";

let _ = ctx.sql(sql).await?.collect().await?;

Ok(())
}
```
To obtain a backtrace:
```bash
cargo build --features=backtrace
RUST_BACKTRACE=1 cargo test --features=backtrace --package datafusion --lib -- physical_planner::tests::test_get_backtrace_for_failed_code --exact --nocapture
```
Note: The backtrace wrapped into systems calls, so some steps on top of the backtrace can be ignored

0 comments on commit 0b5bfe2

Please sign in to comment.