Skip to content

[SPARK-52503][SQL][CONNECT][4.0] Fix drop when the input column is not existent #51348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

zhengruifeng
Copy link
Contributor

cherry-pick #51196 to 4.0

…xistent

Fix `drop` when the input column is not existent

bugfix

```
import pyspark.sql.functions as F

df1 = spark.createDataFrame([("a", "b", "c") ], schema='colA string, colB string, colC string')

df2 = spark.createDataFrame([("c", "d", "") ], schema='colC string, colD string, colE string')

df3 = df1.join(df2, df1["colC"] == df2["colC"]).withColumn("colB", F.when(df1["colB"] == "b", F.concat(df1["colB"].cast("string"), F.lit("_newValue"))).otherwise(df1["colB"]))

df3
DataFrame[colA: string, colB: string, colC: string, colC: string, colD: string, colE: string]

df3.drop(df1["colB"])
DataFrame[colA: string, colC: string, colC: string, colD: string, colE: string]
```

`df3` doesn't contains `df1["colB"]`, so no columns should be dropped.

yes, bug fix

added tests

no

Closes apache#51196 from zhengruifeng/fix_drop_col.

Authored-by: Ruifeng Zheng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
@zhengruifeng zhengruifeng requested a review from cloud-fan July 2, 2025 11:49
zhengruifeng added a commit that referenced this pull request Jul 3, 2025
…t existent

cherry-pick #51196 to 4.0

Closes #51348 from zhengruifeng/fix_drop_col_4.

Authored-by: Ruifeng Zheng <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
@zhengruifeng
Copy link
Contributor Author

merged to 4.0

@zhengruifeng zhengruifeng deleted the fix_drop_col_4 branch July 3, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants