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

Commit

Permalink
Overload DataFrame.drop: sequences must be *str (#377)
Browse files Browse the repository at this point in the history
* Overload DataFrame.drop: sequences must be *str
  • Loading branch information
oliverw1 authored Feb 17, 2020
1 parent 73570d4 commit 7d95746
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions test-data/unit/sql-dataframe.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ df.sample(withReplacement=False) # E: No overload variant of "sample" of "DataFr
[out]


[case dropColumns]
from pyspark.sql import SparkSession
from pyspark.sql.functions import lit, col
spark = SparkSession.builder.getOrCreate()
df = spark.range(1)
df.drop("id")
df.drop("id", "foo")
df.drop(df.id)

df.drop(col("id"), col("foo")) # E: No overload variant of "drop" of "DataFrame" matches argument types "Column", "Column" \
# N: Possible overload variant: \
# N: def drop(self, *cols: str) -> DataFrame \
# N: <1 more non-matching overload not shown>

[out]
5 changes: 4 additions & 1 deletion third_party/3/pyspark/sql/dataframe.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ class DataFrame(PandasMapOpsMixin, PandasConversionMixin):
) -> DataFrame: ...
def withColumn(self, colName: str, col: Column) -> DataFrame: ...
def withColumnRenamed(self, existing: str, new: str) -> DataFrame: ...
def drop(self, *cols: ColumnOrName) -> DataFrame: ...
@overload
def drop(self, cols: ColumnOrName) -> DataFrame: ...
@overload
def drop(self, *cols: str) -> DataFrame: ...
def toDF(self, *cols: ColumnOrName) -> DataFrame: ...
def transform(self, func: Callable[[DataFrame], DataFrame]) -> DataFrame: ...
@overload
Expand Down

0 comments on commit 7d95746

Please sign in to comment.