-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: Fix duplicate column output and panic for include_file_paths
#18255
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 |
---|---|---|
|
@@ -1171,8 +1171,15 @@ impl DataFrame { | |
/// # Safety | ||
/// The caller must ensure `column.len() == self.height()` . | ||
pub unsafe fn with_column_unchecked(&mut self, column: Series) -> &mut Self { | ||
self.get_columns_mut().push(column); | ||
self | ||
#[cfg(debug_assertions)] | ||
{ | ||
return self.with_column(column).unwrap(); | ||
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. drive-by - enable checks here in debug mode to prevent similar mistakes |
||
} | ||
#[cfg(not(debug_assertions))] | ||
{ | ||
self.get_columns_mut().push(column); | ||
self | ||
} | ||
} | ||
|
||
fn add_column_by_schema(&mut self, s: Series, schema: &Schema) -> PolarsResult<()> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,15 +187,14 @@ impl ParquetExec { | |
readers_and_metadata | ||
.into_par_iter() | ||
.zip(row_statistics.into_par_iter()) | ||
.enumerate() | ||
.map( | ||
|(i, ((reader, _, predicate, projection), (cumulative_read, slice)))| { | ||
|((reader, _, predicate, projection), (cumulative_read, slice))| { | ||
let row_index = base_row_index.as_ref().map(|rc| RowIndex { | ||
name: rc.name.clone(), | ||
offset: rc.offset + cumulative_read as IdxSize, | ||
}); | ||
|
||
let mut df = reader | ||
let df = reader | ||
.with_slice(Some(slice)) | ||
.with_row_index(row_index) | ||
.with_predicate(predicate.clone()) | ||
|
@@ -210,20 +209,6 @@ impl ParquetExec { | |
)? | ||
.finish()?; | ||
|
||
if let Some(col) = &self.file_options.include_file_paths { | ||
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. This was duplicate from a very old implementation approach that didn't push |
||
let path = paths[i].to_str().unwrap(); | ||
unsafe { | ||
df.with_column_unchecked( | ||
StringChunked::full( | ||
col, | ||
path, | ||
std::cmp::max(df.height(), slice.1), | ||
) | ||
.into_series(), | ||
) | ||
}; | ||
} | ||
|
||
Ok(df) | ||
}, | ||
) | ||
|
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.
index and length were flipped on the trait definition