jayzhan211 commented on code in PR #8744:
URL: https://github.com/apache/arrow-datafusion/pull/8744#discussion_r1442517967
##########
datafusion/common/src/utils.rs:
##########
@@ -492,6 +496,58 @@ pub fn list_ndims(data_type: &DataType) -> u64 {
}
}
+/// Create an new empty array based on the given data type.
+pub fn empty_list(data_type: &DataType) -> Result<ArrayRef> {
+ match data_type {
+ DataType::Boolean => Ok(Arc::new(BooleanArray::from(vec![None]))),
+ DataType::UInt8 => Ok(Arc::new(UInt8Array::from(vec![None]))),
+ DataType::UInt16 => Ok(Arc::new(UInt16Array::from(vec![None]))),
+ DataType::UInt32 => Ok(Arc::new(UInt32Array::from(vec![None]))),
+ DataType::UInt64 => Ok(Arc::new(UInt64Array::from(vec![None]))),
+ DataType::Int8 => Ok(Arc::new(Int8Array::from(vec![None]))),
+ DataType::Int16 => Ok(Arc::new(Int16Array::from(vec![None]))),
+ DataType::Int32 => Ok(Arc::new(Int32Array::from(vec![None]))),
+ DataType::Int64 => Ok(Arc::new(Int64Array::from(vec![None]))),
+ DataType::Float32 => Ok(Arc::new(Float32Array::from(vec![None]))),
+ DataType::Float64 => Ok(Arc::new(Float64Array::from(vec![None]))),
+ DataType::List(field) => {
+ let value = empty_list(field.data_type())?;
+ Ok(Arc::new(ListArray::try_new(
+ field.clone(),
+ OffsetBuffer::new(vec![0, 0].into()),
+ value,
+ None,
+ )?))
+ }
+ DataType::LargeList(field) => {
+ let value = empty_list(field.data_type())?;
+
+ Ok(Arc::new(LargeListArray::try_new(
+ field.clone(),
+ OffsetBuffer::new(vec![0, 0].into()),
+ value,
+ None,
+ )?))
+ }
+ DataType::Null => Ok(Arc::new(NullArray::new(1))),
+ _ => _internal_err!("Unsupported data type for empty list: {:?}",
data_type),
+ }
+}
+
+// DataType::Boolean,
Review Comment:
I think you forgot to cleanup this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]