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

Commit

Permalink
Allow comparsion between Column and datetime objects (#274)
Browse files Browse the repository at this point in the history
Resoves #273
  • Loading branch information
zero323 committed Dec 30, 2019
1 parent 84a927b commit 76db4a4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
21 changes: 21 additions & 0 deletions test-data/unit/sql-column.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[case colDateTimeCompare]
import datetime
from pyspark.sql.functions import col

today = datetime.date.today()
now = datetime.datetime.now()
a_col = col("")

a_col < today
a_col <= today
a_col == today
a_col >= today
a_col > today


a_col < now
a_col <= now
a_col == now
a_col >= now
a_col > now
[out]
1 change: 1 addition & 0 deletions tests/unit/testpyspark.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ml-param.test",
"ml-readable.test",
"resultiterable.test",
"sql-column.test",
"sql-readwriter.test",
"sql-udf.test",
]
10 changes: 5 additions & 5 deletions third_party/3/pyspark/sql/column.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class Column:
def __rmod__(self, other: Union[bool, int, float, DecimalLiteral]) -> Column: ...
def __pow__(self, other: Union[Column, LiteralType, DecimalLiteral]) -> Column: ...
def __rpow__(self, other: Union[LiteralType, DecimalLiteral]) -> Column: ...
def __eq__(self, other: Union[Column, LiteralType, DecimalLiteral]) -> Column: ... # type: ignore
def __eq__(self, other: Union[Column, LiteralType, DateTimeLiteral, DecimalLiteral]) -> Column: ... # type: ignore
def __ne__(self, other: Any) -> Column: ... # type: ignore
def __lt__(self, other: Union[Column, LiteralType, DecimalLiteral]) -> Column: ...
def __le__(self, other: Union[Column, LiteralType, DecimalLiteral]) -> Column: ...
def __ge__(self, other: Union[Column, LiteralType, DecimalLiteral]) -> Column: ...
def __gt__(self, other: Union[Column, LiteralType, DecimalLiteral]) -> Column: ...
def __lt__(self, other: Union[Column, LiteralType, DateTimeLiteral, DecimalLiteral]) -> Column: ...
def __le__(self, other: Union[Column, LiteralType, DateTimeLiteral, DecimalLiteral]) -> Column: ...
def __ge__(self, other: Union[Column, LiteralType, DateTimeLiteral, DecimalLiteral]) -> Column: ...
def __gt__(self, other: Union[Column, LiteralType, DateTimeLiteral, DecimalLiteral]) -> Column: ...
def eqNullSafe(self, other: Union[Column, LiteralType, DecimalLiteral]) -> Column: ...
def __and__(self, other: Column) -> Column: ...
def __or__(self, other: Column) -> Column: ...
Expand Down

0 comments on commit 76db4a4

Please sign in to comment.