2010YOUY01 commented on code in PR #17204: URL: https://github.com/apache/datafusion/pull/17204#discussion_r2278557812
########## datafusion-cli/tests/cli_integration.rs: ########## @@ -332,3 +332,31 @@ SELECT COUNT(*) FROM hits; .env_remove("AWS_ENDPOINT") .pass_stdin(input)); } + +/// Ensure backtrace will be printed, if executing `datafusion-cli` with a query +/// that triggers error. +/// Example: +/// RUST_BACKTRACE=1 cargo run --features backtrace -- -c 'select pow(1,'foo');' +#[rstest] +#[case("SELECT pow(1,'foo')")] +#[case("SELECT CAST('not_a_number' AS INTEGER);")] +fn test_backtrace_output(#[case] query: &str) { + let mut cmd = cli(); + // Use a command that will cause an error and trigger backtrace + cmd.args(["--command", query, "-q"]) + .env("RUST_BACKTRACE", "1"); // Enable backtrace + + let output = cmd.output().expect("Failed to execute command"); + let stdout = String::from_utf8_lossy(&output.stdout); + let stderr = String::from_utf8_lossy(&output.stderr); + let combined_output = format!("{}{}", stdout, stderr); + + // Assert that the output includes literal 'backtrace' + // Note: The user mentioned backtrace isn't working yet, but we test for the literal string Review Comment: ```suggestion // Assert that the output includes literal 'backtrace' ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org