Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(connect): df.dtypes #3377

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/connect/test_dtypes.py
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"
Loading