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

[FEAT] connect: Add support for select #3344

Merged
merged 1 commit into from
Nov 21, 2024
Merged
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
20 changes: 20 additions & 0 deletions tests/connect/test_select.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import annotations

from pyspark.sql.functions import col


def test_select(spark_session):
# Create DataFrame from range(10)
df = spark_session.range(10)
graphite-app[bot] marked this conversation as resolved.
Show resolved Hide resolved
graphite-app[bot] marked this conversation as resolved.
Show resolved Hide resolved
graphite-app[bot] marked this conversation as resolved.
Show resolved Hide resolved
graphite-app[bot] marked this conversation as resolved.
Show resolved Hide resolved

# Select just the 'id' column
df_selected = df.select(col("id"))

# Verify the schema is unchanged since we selected same column
assert df_selected.schema == df.schema, "Schema should be unchanged after selecting same column"
assert len(df_selected.collect()) == 10, "Row count should be unchanged after select"

# Verify the data is unchanged
df_data = [row["id"] for row in df.collect()]
df_selected_data = [row["id"] for row in df_selected.collect()]
assert df_data == df_selected_data, "Data should be unchanged after select"