-
Notifications
You must be signed in to change notification settings - Fork 175
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: createDataFrame
(WIP) help needed
#3376
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use daft_logical_plan::LogicalPlanBuilder; | ||
|
||
pub fn local_relation( | ||
local_relation: spark_connect::LocalRelation, | ||
) -> eyre::Result<LogicalPlanBuilder> { | ||
let spark_connect::LocalRelation { | ||
data, | ||
schema, | ||
} = local_relation; | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use eyre::{bail, WrapErr}; | ||
use daft_logical_plan::LogicalPlanBuilder; | ||
use crate::translation::to_logical_plan; | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Spotted by Graphite Reviewer |
||
|
||
pub fn to_df(to_df: spark_connect::ToDf) -> eyre::Result<LogicalPlanBuilder> { | ||
let spark_connect::ToDf { | ||
input, | ||
column_names, | ||
} = to_df; | ||
|
||
let Some(input) = input else { | ||
bail!("Input is required") | ||
}; | ||
|
||
let plan = to_logical_plan(*input) | ||
.wrap_err_with(|| format!("Failed to translate relation to logical plan: {input:?}"))?; | ||
|
||
let column_names: Vec<_> = column_names | ||
.iter() | ||
.map(|name| daft_dsl::col(name)) | ||
.collect(); | ||
|
||
let plan = plan.with_columns(column_names)? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon at the end of Spotted by Graphite Reviewer |
||
|
||
Ok(plan) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import annotations | ||
|
||
|
||
def test_create_df(spark_session): | ||
# Create a DataFrame with duplicate values | ||
data = [(1,), (2,), (2,), (3,), (3,), (3,)] | ||
df = spark_session.createDataFrame(data, ["value"]) | ||
|
||
# Collect and verify results | ||
result = df.collect() | ||
|
||
# Verify the DataFrame has the expected number of rows and values | ||
assert sorted([row.value for row in result]) == [1, 2, 2, 3, 3, 3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function needs to be completed - it currently lacks a return value and implementation. The function should process the
data
andschema
parameters to construct and return aLogicalPlanBuilder
. Consider adding error handling for invalid data or schema formats.Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.