-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c026db1
commit 7a201d4
Showing
1 changed file
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import annotations | ||
|
||
from pyspark.sql.functions import col | ||
|
||
|
||
def test_dtypes(spark_session): | ||
# Create DataFrame from range(10) | ||
df = spark_session.range(10) | ||
|
||
# Add a column that will have repeated values for grouping | ||
df = df.withColumn("group", col("id") % 3) | ||
|
||
# Check dtypes of the DataFrame | ||
expected_dtypes = [ | ||
("id", "bigint"), | ||
("group", "bigint") | ||
] | ||
|
||
# Get actual dtypes | ||
actual_dtypes = df.dtypes | ||
|
||
# Verify the dtypes match expected | ||
assert actual_dtypes == expected_dtypes | ||
|
||
# Also check individual column types | ||
assert df.schema["id"].dataType.simpleString() == "bigint" | ||
assert df.schema["group"].dataType.simpleString() == "bigint" |