martin-g commented on code in PR #18623:
URL: https://github.com/apache/datafusion/pull/18623#discussion_r2517094111


##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -305,6 +305,17 @@ async fn select_columns() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn select_columns_with_nonexistent_columns() -> Result<()> {
+    let t = test_table().await?;
+    let t2 = t.select_columns(&["canada", "c2", "rocks"]);
+    let Err(DataFusionError::SchemaError(_, _)) = t2 else {
+        return internal_err!("select_columns with nonexistent columns should 
error");
+    };

Review Comment:
   My personal preference for asserting on errors would be:
   ```rust
   let t2 = t.select_columns(&["canada", "c2", "rocks"]);
   match t2 {
       Err(DataFusionError::SchemaError(SchemaError::FieldNotFound { field, .. 
}, _)) => {
           // Verify it's the first invalid column
           assert_eq!(field.name(), "canada");
       }
       _ => panic!("Expected SchemaError::FieldNotFound for 'canada'"),
   }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to