kosiew commented on code in PR #25857:
URL: https://github.com/apache/datafusion/pull/25857#discussion_r4334087704


##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -7029,6 +7029,106 @@ async fn test_fill_nan_uncastable_value() -> Result<()> 
{
     Ok(())
 }
 
+#[rstest]
+#[tokio::test]
+async fn test_fill_special_column_names(
+    #[values(false, true)] fill_nan: bool,
+    #[values("Name", "a.b")] name: &str,
+    #[values(false, true)] uncastable: bool,
+) -> Result<()> {
+    let fill = if fill_nan {
+        DataFrame::fill_nan
+    } else {
+        DataFrame::fill_null
+    };
+    let missing = if fill_nan { Some(f64::NAN) } else { None };
+    let other_name = if name == "Name" { "a.b" } else { "Name" };
+    let schema = Arc::new(Schema::new(vec![
+        Field::new(name, DataType::Float64, true),
+        Field::new(other_name, DataType::Utf8, true),
+    ]));
+    let batch = RecordBatch::try_new(
+        schema,
+        vec![
+            Arc::new(Float64Array::from(vec![Some(1.0), missing, Some(3.0)])),
+            Arc::new(StringArray::from(vec![Some("a"), None, Some("c")])),
+        ],
+    )?;
+    let ctx = SessionContext::new();
+    let df = ctx.read_batch(batch.clone())?;
+    let value = if uncastable {
+        ScalarValue::from("abc")
+    } else {
+        ScalarValue::from(0.0)
+    };
+
+    let results = fill(&df, &value, &[name])?.collect().await?;
+    let expected = if uncastable {
+        // An uncastable replacement leaves the selected column unchanged.
+        batch
+    } else {
+        RecordBatch::try_new(
+            batch.schema(),
+            vec![
+                Arc::new(Float64Array::from(vec![1.0, 0.0, 3.0])),
+                Arc::clone(batch.column(1)),
+            ],
+        )?
+    };
+    // Both selected and untouched names must be preserved literally.
+    assert_eq!(batches_to_string(&results), batches_to_string(&[expected]));

Review Comment:
   Consider asserting the collected schema's field names and types directly. 
The formatted comparison checks headers and values but cannot distinguish 
numeric types with identical output; no need to require unchanged nullability.



-- 
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