blaginin commented on code in PR #16184: URL: https://github.com/apache/datafusion/pull/16184#discussion_r2106938898
########## datafusion/expr/src/logical_plan/builder.rs: ########## @@ -2592,19 +2587,29 @@ mod tests { let err = nested_table_scan("test_table")? .unnest_column("scalar") .unwrap_err(); - assert!(err - .to_string() - .starts_with("Internal error: trying to unnest on invalid data type UInt32")); + + let DataFusionError::Internal(desc) = err else { + return plan_err!("Plan should have returned an DataFusionError::Internal"); + }; + + let desc = desc + .split(DataFusionError::BACK_TRACE_SEP) + .collect::<Vec<&str>>() + .first() + .unwrap_or(&"") + .to_string(); + + assert_snapshot!(desc, @"trying to unnest on invalid data type UInt32"); Review Comment: what do you think about ```suggestion assert_snapshot!(err.strip_backtrace(), @r" Internal error: trying to unnest on invalid data type UInt32. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker "); ``` that way, we won't have to manually split on the string ########## datafusion/expr/src/logical_plan/builder.rs: ########## @@ -2420,14 +2414,15 @@ mod tests { .filter(exists(Arc::new(subquery)))? .build()?; - let expected = "Filter: EXISTS (<subquery>)\ - \n Subquery:\ - \n Filter: foo.a = bar.a\ - \n Projection: foo.a\ - \n TableScan: foo\ - \n Projection: bar.a\ - \n TableScan: bar"; - assert_eq!(expected, format!("{outer_query}")); + assert_snapshot!(format!("{outer_query}"), @r" Review Comment: ```suggestion assert_snapshot!(outer_query, @r" ``` ########## datafusion/expr/src/logical_plan/display.rs: ########## @@ -722,13 +722,14 @@ impl<'n> TreeNodeVisitor<'n> for PgJsonVisitor<'_, '_> { #[cfg(test)] mod tests { use arrow::datatypes::{DataType, Field}; + use insta::assert_snapshot; use super::*; #[test] fn test_display_empty_schema() { let schema = Schema::empty(); - assert_eq!("[]", format!("{}", display_schema(&schema))); + assert_snapshot!(format!("{}", display_schema(&schema)), @"[]"); Review Comment: ```suggestion assert_snapshot!(display_schema(&schema), @"[]"); ``` ########## datafusion/expr/src/logical_plan/builder.rs: ########## @@ -2420,14 +2414,15 @@ mod tests { .filter(exists(Arc::new(subquery)))? .build()?; - let expected = "Filter: EXISTS (<subquery>)\ - \n Subquery:\ - \n Filter: foo.a = bar.a\ - \n Projection: foo.a\ - \n TableScan: foo\ - \n Projection: bar.a\ - \n TableScan: bar"; - assert_eq!(expected, format!("{outer_query}")); + assert_snapshot!(format!("{outer_query}"), @r" Review Comment: i think there are a few remaining places like this - can you please check? 🙏🏻 -- 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