-
Notifications
You must be signed in to change notification settings - Fork 4.1k
ARROW-7842: [Rust] [Parquet] implement array_reader for list type columns #6770
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
Changes from 8 commits
5acff2c
3fb8fb5
48ee841
dd4b109
f9411f1
f4e70fd
8c8efa1
feb72d3
57132e6
6f90636
cef96c0
334ce05
360e086
abc2a70
deb7edf
70d40db
1de5b9b
e24df6e
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 |
|---|---|---|
|
|
@@ -828,8 +828,8 @@ mod tests { | |
| .build()?; | ||
|
|
||
| let expected = "Projection: #id\ | ||
| \n Selection: #state Eq Utf8(\"CO\")\ | ||
| \n TableScan: employee.csv projection=Some([0, 3])"; | ||
| \n Selection: #state Eq Utf8(\"CO\")\ | ||
| \n TableScan: employee.csv projection=Some([0, 3])"; | ||
|
|
||
|
Member
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. Are these formatting changes from running rustfmt?
Author
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. yes |
||
| assert_eq!(expected, format!("{:?}", plan)); | ||
|
|
||
|
|
@@ -852,9 +852,10 @@ mod tests { | |
| .project(vec![col("state"), col("total_salary")])? | ||
| .build()?; | ||
|
|
||
| let expected = "Projection: #state, #total_salary\ | ||
| \n Aggregate: groupBy=[[#state]], aggr=[[SUM(#salary) AS total_salary]]\ | ||
| \n TableScan: employee.csv projection=Some([3, 4])"; | ||
| let expected = | ||
| "Projection: #state, #total_salary\ | ||
| \n Aggregate: groupBy=[[#state]], aggr=[[SUM(#salary) AS total_salary]]\ | ||
|
nevi-me marked this conversation as resolved.
|
||
| \n TableScan: employee.csv projection=Some([3, 4])"; | ||
|
|
||
| assert_eq!(expected, format!("{:?}", plan)); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,22 @@ macro_rules! make_string { | |
| }}; | ||
| } | ||
|
|
||
| macro_rules! make_string_from_list { | ||
| ($column: ident, $row: ident) => {{ | ||
| let list = $column | ||
| .as_any() | ||
| .downcast_ref::<array::ListArray>() | ||
| .ok_or(ExecutionError::ExecutionError(format!( | ||
| "Repl error: could not convert list column to list array." | ||
| )))? | ||
| .value($row); | ||
| let string_values = (0..list.len()) | ||
| .map(|i| array_value_to_string(list.clone(), i)) | ||
| .collect::<Result<Vec<String>>>()?; | ||
| Ok(format!("[{}]", string_values.join(", "))) | ||
| }}; | ||
| } | ||
|
|
||
| /// Get the value at the given row in an array as a string | ||
| pub fn array_value_to_string(column: array::ArrayRef, row: usize) -> Result<String> { | ||
| match column.data_type() { | ||
|
|
@@ -120,6 +136,7 @@ pub fn array_value_to_string(column: array::ArrayRef, row: usize) -> Result<Stri | |
| DataType::Time64(unit) if *unit == TimeUnit::Nanosecond => { | ||
| make_string!(array::Time64NanosecondArray, column, row) | ||
| } | ||
| DataType::List(_) => make_string_from_list!(column, row), | ||
|
Member
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. Does it matter what data type the list is? Can lists of any type be converted into strings?
Author
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 recursively calls |
||
| _ => Err(ExecutionError::ExecutionError(format!( | ||
| "Unsupported {:?} type for repl.", | ||
| column.data_type() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.