File tree Expand file tree Collapse file tree
core/src/datasource/file_format
spark/src/function/bitwise Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -322,7 +322,7 @@ jobs:
322322 AWS_SECRET_ACCESS_KEY : TEST-DataFusionPassword
323323 TEST_STORAGE_INTEGRATION : 1
324324 AWS_ALLOW_HTTP : true
325- run : cargo test --profile ci -p datafusion-cli --lib --tests --bins
325+ run : cargo test --features backtrace -- profile ci -p datafusion-cli --lib --tests --bins
326326 - name : Verify Working Directory Clean
327327 run : git diff --exit-code
328328
Original file line number Diff line number Diff line change @@ -332,3 +332,30 @@ SELECT COUNT(*) FROM hits;
332332 . env_remove( "AWS_ENDPOINT" )
333333 . pass_stdin( input) ) ;
334334}
335+
336+ /// Ensure backtrace will be printed, if executing `datafusion-cli` with a query
337+ /// that triggers error.
338+ /// Example:
339+ /// RUST_BACKTRACE=1 cargo run --features backtrace -- -c 'select pow(1,'foo');'
340+ #[ rstest]
341+ #[ case( "SELECT pow(1,'foo')" ) ]
342+ #[ case( "SELECT CAST('not_a_number' AS INTEGER);" ) ]
343+ fn test_backtrace_output ( #[ case] query : & str ) {
344+ let mut cmd = cli ( ) ;
345+ // Use a command that will cause an error and trigger backtrace
346+ cmd. args ( [ "--command" , query, "-q" ] )
347+ . env ( "RUST_BACKTRACE" , "1" ) ; // Enable backtrace
348+
349+ let output = cmd. output ( ) . expect ( "Failed to execute command" ) ;
350+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
351+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
352+ let combined_output = format ! ( "{}{}" , stdout, stderr) ;
353+
354+ // Assert that the output includes literal 'backtrace'
355+ assert ! (
356+ combined_output. to_lowercase( ) . contains( "backtrace" ) ,
357+ "Expected output to contain 'backtrace', but got stdout: '{}' stderr: '{}'" ,
358+ stdout,
359+ stderr
360+ ) ;
361+ }
Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ impl From<io::Error> for DataFusionError {
276276
277277impl From < ArrowError > for DataFusionError {
278278 fn from ( e : ArrowError ) -> Self {
279- DataFusionError :: ArrowError ( Box :: new ( e) , None )
279+ DataFusionError :: ArrowError ( Box :: new ( e) , Some ( DataFusionError :: get_back_trace ( ) ) )
280280 }
281281}
282282
Original file line number Diff line number Diff line change @@ -515,7 +515,7 @@ mod tests {
515515 assert ! ( err. is_err( ) ) ;
516516 assert_eq ! (
517517 "Arrow error: Parser error: Unexpected end of byte stream for Arrow IPC file" ,
518- err. unwrap_err( ) . to_string( )
518+ err. unwrap_err( ) . to_string( ) . lines ( ) . next ( ) . unwrap ( )
519519 ) ;
520520
521521 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -234,14 +234,20 @@ mod tests {
234234 Arc :: new ( Int64Array :: from ( vec ! [ 11 ] ) ) ,
235235 Arc :: new ( Int32Array :: from ( vec ! [ -1 ] ) ) ,
236236 ] ) ;
237- assert_eq ! ( result. unwrap_err( ) . message( ) , "Compute error: bit_get: position -1 is out of bounds. Expected pos < 64 and pos >= 0" ) ;
237+ assert_eq ! (
238+ result. unwrap_err( ) . message( ) . lines( ) . next( ) . unwrap( ) ,
239+ "Compute error: bit_get: position -1 is out of bounds. Expected pos < 64 and pos >= 0"
240+ ) ;
238241
239242 let result = spark_bit_get ( & [
240243 Arc :: new ( Int64Array :: from ( vec ! [ 11 ] ) ) ,
241244 Arc :: new ( Int32Array :: from ( vec ! [ 64 ] ) ) ,
242245 ] ) ;
243246
244- assert_eq ! ( result. unwrap_err( ) . message( ) , "Compute error: bit_get: position 64 is out of bounds. Expected pos < 64 and pos >= 0" ) ;
247+ assert_eq ! (
248+ result. unwrap_err( ) . message( ) . lines( ) . next( ) . unwrap( ) ,
249+ "Compute error: bit_get: position 64 is out of bounds. Expected pos < 64 and pos >= 0"
250+ ) ;
245251 }
246252
247253 #[ test]
You can’t perform that action at this time.
0 commit comments