Skip to content

Commit

Permalink
Adding backtrace documentation (#7628)
Browse files Browse the repository at this point in the history
  • Loading branch information
comphead authored Sep 23, 2023
1 parent dab68a3 commit 9b45ed9
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions docs/source/user-guide/example-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Even [`more code examples`](../../../datafusion-examples) attached to the projec

## Update `Cargo.toml`

Add the following to your `Cargo.toml` file:
Find latest available Datafusion version on [DataFusion's
crates.io] page. Add the dependency to your `Cargo.toml` file:

```toml
datafusion = "26"
datafusion = "31"
tokio = "1.0"
```

Expand Down Expand Up @@ -232,3 +233,37 @@ with `native` or at least `avx2`.
```shell
RUSTFLAGS='-C target-cpu=native' cargo +nightly run --release
```

## Enable backtraces

By default Datafusion returns errors as a plain message. There is option to enable more verbose details about the error,
like error backtrace. To enable a backtrace you need to add Datafusion `backtrace` feature to your `Cargo.toml` file:

```toml
datafusion = { version = "31.0.0", features = ["backtrace"]}
```

Set environment [`variables`] https://doc.rust-lang.org/std/backtrace/index.html#environment-variables

```bash
RUST_BACKTRACE=1 ./target/debug/datafusion-cli
DataFusion CLI v31.0.0
select row_numer() over (partition by a order by a) from (select 1 a);
Error during planning: Invalid function 'row_numer'.
Did you mean 'ROW_NUMBER'?

backtrace: 0: std::backtrace_rs::backtrace::libunwind::trace
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: std::backtrace::Backtrace::create
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/backtrace.rs:332:13
3: std::backtrace::Backtrace::capture
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/backtrace.rs:298:9
4: datafusion_common::error::DataFusionError::get_back_trace
at /arrow-datafusion/datafusion/common/src/error.rs:436:30
5: datafusion_sql::expr::function::<impl datafusion_sql::planner::SqlToRel<S>>::sql_function_to_expr
............
```
Note: The backtrace wrapped into systems calls, so some steps on top of the backtrace can be ignored

0 comments on commit 9b45ed9

Please sign in to comment.