-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11935 from mariotaddeucci/feature/pyspark-functions
[Python] Add pyspark hash and organize unit tests
- Loading branch information
Showing
4 changed files
with
130 additions
and
17 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
30 changes: 30 additions & 0 deletions
30
tools/pythonpkg/tests/fast/spark/test_spark_functions_hash.py
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,30 @@ | ||
import pytest | ||
|
||
_ = pytest.importorskip("duckdb.experimental.spark") | ||
from duckdb.experimental.spark.sql import functions as F | ||
|
||
|
||
class TestSparkFunctionsHash(object): | ||
def test_md5(self, spark): | ||
data = [ | ||
("quack",), | ||
] | ||
res = ( | ||
spark.createDataFrame(data, ["firstColumn"]) | ||
.withColumn("hashed_value", F.md5(F.col("firstColumn"))) | ||
.select("hashed_value") | ||
.collect() | ||
) | ||
assert res[0].hashed_value == "cfaf278e8f522c72644cee2a753d2845" | ||
|
||
def test_sha256(self, spark): | ||
data = [ | ||
("quack",), | ||
] | ||
res = ( | ||
spark.createDataFrame(data, ["firstColumn"]) | ||
.withColumn("hashed_value", F.sha2(F.col("firstColumn"), 256)) | ||
.select("hashed_value") | ||
.collect() | ||
) | ||
assert res[0].hashed_value == "82d928273d067d774889d5df4249aaf73c0b04c64f04d6ed001441ce87a0853c" |
4 changes: 2 additions & 2 deletions
4
...ast/spark/test_spark_numeric_functions.py → ...ast/spark/test_spark_functions_numeric.py
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
4 changes: 2 additions & 2 deletions
4
...fast/spark/test_spark_string_functions.py → ...fast/spark/test_spark_functions_string.py
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