Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 7d95746

Browse files
authored
Overload DataFrame.drop: sequences must be *str (#377)
* Overload DataFrame.drop: sequences must be *str
1 parent 73570d4 commit 7d95746

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

test-data/unit/sql-dataframe.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,18 @@ df.sample(withReplacement=False) # E: No overload variant of "sample" of "DataFr
2222
[out]
2323

2424

25+
[case dropColumns]
26+
from pyspark.sql import SparkSession
27+
from pyspark.sql.functions import lit, col
28+
spark = SparkSession.builder.getOrCreate()
29+
df = spark.range(1)
30+
df.drop("id")
31+
df.drop("id", "foo")
32+
df.drop(df.id)
33+
34+
df.drop(col("id"), col("foo")) # E: No overload variant of "drop" of "DataFrame" matches argument types "Column", "Column" \
35+
# N: Possible overload variant: \
36+
# N: def drop(self, *cols: str) -> DataFrame \
37+
# N: <1 more non-matching overload not shown>
38+
39+
[out]

third_party/3/pyspark/sql/dataframe.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ class DataFrame(PandasMapOpsMixin, PandasConversionMixin):
211211
) -> DataFrame: ...
212212
def withColumn(self, colName: str, col: Column) -> DataFrame: ...
213213
def withColumnRenamed(self, existing: str, new: str) -> DataFrame: ...
214-
def drop(self, *cols: ColumnOrName) -> DataFrame: ...
214+
@overload
215+
def drop(self, cols: ColumnOrName) -> DataFrame: ...
216+
@overload
217+
def drop(self, *cols: str) -> DataFrame: ...
215218
def toDF(self, *cols: ColumnOrName) -> DataFrame: ...
216219
def transform(self, func: Callable[[DataFrame], DataFrame]) -> DataFrame: ...
217220
@overload

0 commit comments

Comments
 (0)