Skip to content
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

Implement non-nested struct statistic extraction #10730

Closed
wants to merge 7 commits into from

Conversation

Lordworms
Copy link
Contributor

Which issue does this PR close?

Closes #10609

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label May 30, 2024
@Lordworms
Copy link
Contributor Author

Did not implement the nested struct type since the current RowGroupMetaData and ColumnChunkMetaData seems not to support nesting
image
image

@@ -1155,7 +1155,6 @@ async fn test_boolean() {
// BUG
// https://github.com/apache/datafusion/issues/10609
// Note that: since I have not worked on struct array before, there may be a bug in the test code rather than the real bug in the code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we can update the comments here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Lordworms

}
match field.data_type() {
DataType::Struct(_) => {
let parquet_idx = (0..parquet_schema.columns().len())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tustvold could you help here -- is this the correct way to find the correct parquet leaf from an arrow struct type?

@@ -1168,7 +1165,7 @@ async fn test_struct() {
reader: reader.build().await,
expected_min: Arc::new(struct_array(vec![(Some(1), Some(6.0), Some(12.0))])),
expected_max: Arc::new(struct_array(vec![(Some(2), Some(8.5), Some(14.0))])),
expected_null_counts: UInt64Array::from(vec![0]),
expected_null_counts: UInt64Array::from(vec![2]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something isn't right here -- the structs themselves aren't nullable (only some of their child fields)

let struct_array_data = struct_array(vec![
(Some(1), Some(6.0), Some(12.0)),
(Some(2), Some(8.5), None),
(None, Some(8.5), Some(14.0)),
]);

fn struct_array(input: Vec<(Option<i32>, Option<f32>, Option<f64>)>) -> ArrayRef {
let int_32: Int32Array = input.iter().map(|(i, _, _)| i).collect();
let float_32: Float32Array = input.iter().map(|(_, f, _)| f).collect();
let float_64: Float64Array = input.iter().map(|(_, _, f)| f).collect();
let nullable = true;
let struct_array = StructArray::from(vec![
(
Arc::new(Field::new("int32_col", DataType::Int32, nullable)),
Arc::new(int_32) as ArrayRef,
),
(
Arc::new(Field::new("float32_col", DataType::Float32, nullable)),
Arc::new(float_32) as ArrayRef,
),
(
Arc::new(Field::new("float64_col", DataType::Float64, nullable)),
Arc::new(float_64) as ArrayRef,
),
]);
Arc::new(struct_array)
}

return Ok(Arc::new(new_empty_array(&DataType::UInt64)) as ArrayRef);
}

let mut null_count: u64 = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think nulls only have to check the current nulls (not their children's nulls)...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I'll fix it

@Lordworms Lordworms closed this Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect statistics read for struct array in parquet
2 participants