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

add a describe method on DataFrame like Polars #5226

Merged
merged 4 commits into from
Feb 28, 2023
Merged

Conversation

jiangzhx
Copy link
Contributor

@jiangzhx jiangzhx commented Feb 9, 2023

Which issue does this PR close?

Closes #4974 .

@jiangzhx jiangzhx marked this pull request as draft February 9, 2023 13:46
@github-actions github-actions bot added the core Core DataFusion crate label Feb 9, 2023
@jiangzhx
Copy link
Contributor Author

jiangzhx commented Feb 9, 2023

Try to complete this work, there are still many places that can be optimized.
image

@jiangzhx jiangzhx force-pushed the issues/4974 branch 2 times, most recently from 9d0fafe to 7a622c6 Compare February 13, 2023 08:06
@jiangzhx
Copy link
Contributor Author

make describe method return right datatype for record batch。

image

@github-actions github-actions bot added development-process Related to development process of DataFusion documentation Improvements or additions to documentation logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Physical Expressions sql SQL Planner sqllogictest SQL Logic Tests (.slt) substrait and removed substrait logical-expr Logical plan and expressions physical-expr Physical Expressions development-process Related to development process of DataFusion sqllogictest SQL Logic Tests (.slt) optimizer Optimizer rules sql SQL Planner documentation Improvements or additions to documentation labels Feb 24, 2023
@jiangzhx jiangzhx closed this Feb 24, 2023
@github-actions github-actions bot removed the core Core DataFusion crate label Feb 24, 2023
@jiangzhx jiangzhx reopened this Feb 24, 2023
@github-actions github-actions bot added the core Core DataFusion crate label Feb 24, 2023
@jiangzhx jiangzhx marked this pull request as ready for review February 24, 2023 14:39
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 @jiangzhx -- this looks like a very nice addition to DataFusion ❤️

I left some comments -- let me know if anything isn't clear.

And thanks again!

datafusion/core/src/dataframe.rs Outdated Show resolved Hide resolved
datafusion/core/src/dataframe.rs Outdated Show resolved Hide resolved
if field.data_type().is_numeric() {
Field::new(field.name(), DataType::Float64, true)
} else {
Field::new(field.name(), DataType::Utf8, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect that the schema for count and null_count were always Int64 and the schema for min/max were always Utf8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the describe method return schema like this.
image

the each column should have same datatype .
for example :

  • bool_col on count/null_count return Int64 ; error on min/max , so make bool_col datatype UTF8;
  • float_col on count/null_count return Int64 ; on min/max return float, so make float_col datatype Float64

vec![],
fields_iter
.clone()
.filter(|f| matches!(f.data_type().is_numeric(), true))
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why restrict the min/max aggregation to numeric fields?

In order to get the min/max values in all columns to work, you could call cast to cast them to the same datatype

Copy link
Contributor Author

@jiangzhx jiangzhx Feb 27, 2023

Choose a reason for hiding this comment

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

boolean and binary not work with min/max.

filter out DataType::Binary , DataType::Boolean will be better.
!matches!(f.data_type(), DataType::Binary | DataType::Boolean)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

date_string_col, string_col ’s datatype also Binary.
called Result::unwrap() on an Err value: Internal("Min/Max accumulator not implemented for type Binary")

datafusion/core/src/dataframe.rs Outdated Show resolved Hide resolved
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.

Looks good to me -- thank you @jiangzhx

cc @andygrove (as I think this is a neat thing to expose in datafusion-python)

)),
);

let describe_record_batch =
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@alamb alamb merged commit 96aa2a6 into apache:main Feb 28, 2023
@ursabot
Copy link

ursabot commented Feb 28, 2023

Benchmark runs are scheduled for baseline = ea3b965 and contender = 96aa2a6. 96aa2a6 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

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.

Is there a describe method on DataFrame like Polars?
3 participants