-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: changing column enabler from decorator to function
- Loading branch information
Showing
13 changed files
with
185 additions
and
72 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pyspark.sql import Column | ||
from pyspark.sql import functions as F | ||
|
||
from pysparky.typing import ColumnOrName | ||
|
||
|
||
def column_or_name_enabler(*columns: ColumnOrName) -> tuple[Column, ...]: | ||
""" | ||
Enables PySpark functions to accept either column names (as strings) or Column objects. | ||
Parameters: | ||
columns (ColumnOrName): Column names (as strings) or Column objects to be converted. | ||
Returns: | ||
tuple[Column]: A tuple of Column objects. | ||
Example: | ||
>>> column_or_name_enabler("col1", "col2", F.col("col3")) | ||
(Column<b'col1'>, Column<b'col2'>, Column<b'col3'>) | ||
""" | ||
return tuple( | ||
map( | ||
lambda column: F.col(column) if isinstance(column, str) else column, columns | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.