You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "dqkqd (via GitHub)" <gi...@apache.org> on 2025/10/23 20:48:38 UTC

Re: [PR] fix: `select_columns` and `drop_columns` for qualified duplicated field names [datafusion]

dqkqd commented on code in PR #18236:
URL: https://github.com/apache/datafusion/pull/18236#discussion_r2457280332


##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -405,6 +405,55 @@ async fn select_with_periods() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn select_columns_duplicated_names_from_different_qualifiers() -> Result<()> {
+    let t1 = test_table_with_name("t1")
+        .await?
+        .select_columns(&["c1"])?
+        .limit(0, Some(3))?;
+    let t2 = test_table_with_name("t2")
+        .await?
+        .select_columns(&["c1"])?
+        .limit(3, Some(3))?;
+    let t3 = test_table_with_name("t3")
+        .await?
+        .select_columns(&["c1"])?
+        .limit(6, Some(3))?;
+
+    let join_res = t1
+        .join(t2, JoinType::Left, &["t1.c1"], &["t2.c1"], None)?
+        .join(t3, JoinType::Left, &["t1.c1"], &["t3.c1"], None)?;
+    assert_snapshot!(
+        batches_to_sort_string(&join_res.clone().collect().await.unwrap()),
+        @r"
+    +----+----+----+
+    | c1 | c1 | c1 |
+    +----+----+----+
+    | b  | b  |    |
+    | b  | b  |    |
+    | c  |    |    |
+    | d  |    | d  |
+    +----+----+----+
+    "
+    );
+
+    let select_res = join_res.select_columns(&["c1"])?;

Review Comment:
   This line returned `SchemaError` without the code changes.
   
   ```
       Error: SchemaError(AmbiguousReference { field: Column { relation: None, name: "c1" } }, Some(""))
   ```



-- 
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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org