-
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.
Finished adding first monkeypatch and singleton support to install th…
…at monkeypatch. Got first real input+output example working with purely transpiled code. Other minor bumps.
- Loading branch information
Showing
29 changed files
with
2,054 additions
and
80 deletions.
There are no files selected for viewing
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,10 @@ | ||
from pyspark.sql import DataFrame | ||
|
||
from spl_transpiler.runtime.base import enforce_types, Expr | ||
|
||
|
||
@enforce_types | ||
def rename(df: DataFrame, **renames: Expr) -> DataFrame: | ||
for new_name, old_expr in renames.items(): | ||
df = df.withColumnRenamed(old_expr.to_pyspark_expr(), new_name) | ||
return df |
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,10 @@ | ||
from pyspark.sql import DataFrame | ||
|
||
from spl_transpiler.runtime.base import enforce_types, Expr | ||
|
||
|
||
@enforce_types | ||
def spath( | ||
df: DataFrame, path: str, *, input_: Expr = "raw", output: Expr | None = None | ||
) -> DataFrame: | ||
pass |
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,19 @@ | ||
from functools import cache | ||
|
||
from pyspark.sql import DataFrame, functions as F, GroupedData | ||
|
||
|
||
def groupByMaybeExploded(self: DataFrame, by: list) -> GroupedData: | ||
by_strings = [c for c in by if isinstance(c, str)] | ||
return self.withColumns( | ||
{ | ||
c: F.explode(c) | ||
for c, tp in self.dtypes | ||
if c in by_strings and str(tp).lower().startswith("array<") | ||
} | ||
).groupBy(by) | ||
|
||
|
||
@cache | ||
def install_monkeypatches(): | ||
DataFrame._spltranspiler__groupByMaybeExploded = groupByMaybeExploded |
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
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.