-
Notifications
You must be signed in to change notification settings - Fork 1.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
Change ScalarValue::{List, LargeList, FixedSizedList}
to take specific types rather than ArrayRef
#8562
Merged
Merged
Change ScalarValue::{List, LargeList, FixedSizedList}
to take specific types rather than ArrayRef
#8562
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4bc822b
Change ScalarValue::List type signature
6938bd6
Formatting/cleanup
a8585b6
Remove duplicate match statements
da1bf38
Add back scalar eq_array test for List
48bfc92
Formatting
bf1adaf
Reduce code duplication
5fe9329
Merge branch 'main' into scalarvalue-list-sig
rspears74 73d6776
Fix merge conflict
41f0d36
Fix post-merge compile errors
c1ec85e
Remove redundant partial_cmp implementation
alamb 2fd67d9
improve
alamb 84f3fed
Cargo fmt fix
7cf1511
Merge pull request #1 from alamb/alamb/less_copy3
rspears74 38488af
Reduce duplication in formatter
c212877
Reduce more duplication
588671c
Fix test error
2579749
Merge branch 'apache:main' into scalarvalue-list-sig
rspears74 713374c
Merge remote-tracking branch 'apache/main' into scalarvalue-list-sig
alamb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,6 +32,7 @@ use crate::protobuf::{ | |||||
OptimizedLogicalPlanType, OptimizedPhysicalPlanType, PlaceholderNode, RollupNode, | ||||||
}; | ||||||
use arrow::{ | ||||||
array::ArrayRef, | ||||||
datatypes::{ | ||||||
DataType, Field, IntervalMonthDayNanoType, IntervalUnit, Schema, SchemaRef, | ||||||
TimeUnit, UnionMode, | ||||||
|
@@ -1159,13 +1160,11 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue { | |||||
} | ||||||
// ScalarValue::List and ScalarValue::FixedSizeList are serialized using | ||||||
// Arrow IPC messages as a single column RecordBatch | ||||||
ScalarValue::List(arr) | ||||||
| ScalarValue::LargeList(arr) | ||||||
| ScalarValue::FixedSizeList(arr) => { | ||||||
ScalarValue::List(arr) => { | ||||||
// Wrap in a "field_name" column | ||||||
let batch = RecordBatch::try_from_iter(vec![( | ||||||
"field_name", | ||||||
arr.to_owned(), | ||||||
arr.to_owned() as ArrayRef, | ||||||
)]) | ||||||
.map_err(|e| { | ||||||
Error::General( format!("Error creating temporary batch while encoding ScalarValue::List: {e}")) | ||||||
|
@@ -1189,24 +1188,79 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue { | |||||
schema: Some(schema), | ||||||
}; | ||||||
|
||||||
match val { | ||||||
ScalarValue::List(_) => Ok(protobuf::ScalarValue { | ||||||
value: Some(protobuf::scalar_value::Value::ListValue( | ||||||
scalar_list_value, | ||||||
)), | ||||||
}), | ||||||
ScalarValue::LargeList(_) => Ok(protobuf::ScalarValue { | ||||||
value: Some(protobuf::scalar_value::Value::LargeListValue( | ||||||
scalar_list_value, | ||||||
)), | ||||||
}), | ||||||
ScalarValue::FixedSizeList(_) => Ok(protobuf::ScalarValue { | ||||||
value: Some(protobuf::scalar_value::Value::FixedSizeListValue( | ||||||
scalar_list_value, | ||||||
)), | ||||||
}), | ||||||
_ => unreachable!(), | ||||||
} | ||||||
Ok(protobuf::ScalarValue { | ||||||
value: Some(protobuf::scalar_value::Value::ListValue( | ||||||
scalar_list_value, | ||||||
)), | ||||||
}) | ||||||
} | ||||||
ScalarValue::LargeList(arr) => { | ||||||
// Wrap in a "field_name" column | ||||||
let batch = RecordBatch::try_from_iter(vec![( | ||||||
"field_name", | ||||||
arr.to_owned() as ArrayRef, | ||||||
)]) | ||||||
.map_err(|e| { | ||||||
Error::General( format!("Error creating temporary batch while encoding ScalarValue::List: {e}")) | ||||||
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.
Suggested change
|
||||||
})?; | ||||||
|
||||||
let gen = IpcDataGenerator {}; | ||||||
let mut dict_tracker = DictionaryTracker::new(false); | ||||||
let (_, encoded_message) = gen | ||||||
.encoded_batch(&batch, &mut dict_tracker, &Default::default()) | ||||||
.map_err(|e| { | ||||||
Error::General(format!( | ||||||
"Error encoding ScalarValue::List as IPC: {e}" | ||||||
)) | ||||||
})?; | ||||||
|
||||||
let schema: protobuf::Schema = batch.schema().try_into()?; | ||||||
|
||||||
let scalar_list_value = protobuf::ScalarListValue { | ||||||
ipc_message: encoded_message.ipc_message, | ||||||
arrow_data: encoded_message.arrow_data, | ||||||
schema: Some(schema), | ||||||
}; | ||||||
|
||||||
Ok(protobuf::ScalarValue { | ||||||
value: Some(protobuf::scalar_value::Value::LargeListValue( | ||||||
scalar_list_value, | ||||||
)), | ||||||
}) | ||||||
} | ||||||
ScalarValue::FixedSizeList(arr) => { | ||||||
rspears74 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
// Wrap in a "field_name" column | ||||||
let batch = RecordBatch::try_from_iter(vec![( | ||||||
"field_name", | ||||||
arr.to_owned() as ArrayRef, | ||||||
)]) | ||||||
.map_err(|e| { | ||||||
Error::General( format!("Error creating temporary batch while encoding ScalarValue::List: {e}")) | ||||||
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.
Suggested change
|
||||||
})?; | ||||||
|
||||||
let gen = IpcDataGenerator {}; | ||||||
let mut dict_tracker = DictionaryTracker::new(false); | ||||||
let (_, encoded_message) = gen | ||||||
.encoded_batch(&batch, &mut dict_tracker, &Default::default()) | ||||||
.map_err(|e| { | ||||||
Error::General(format!( | ||||||
"Error encoding ScalarValue::List as IPC: {e}" | ||||||
)) | ||||||
})?; | ||||||
|
||||||
let schema: protobuf::Schema = batch.schema().try_into()?; | ||||||
|
||||||
let scalar_list_value = protobuf::ScalarListValue { | ||||||
ipc_message: encoded_message.ipc_message, | ||||||
arrow_data: encoded_message.arrow_data, | ||||||
schema: Some(schema), | ||||||
}; | ||||||
|
||||||
Ok(protobuf::ScalarValue { | ||||||
value: Some(protobuf::scalar_value::Value::FixedSizeListValue( | ||||||
scalar_list_value, | ||||||
)), | ||||||
}) | ||||||
} | ||||||
ScalarValue::Date32(val) => { | ||||||
create_proto_scalar(val.as_ref(), &data_type, |s| Value::Date32Value(*s)) | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would it be possible to avoid the copy/paste in this method by making a function? Something like the following?
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 one was easy enough to implement.