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

Normalize numeric dtypes when loading/reading from IO #470

Merged

Conversation

philss
Copy link
Member

@philss philss commented Jan 12, 2023

The idea is to keep the numeric dtypes only using Int64 for integers or Float64 for floats.

I tested with some parquet files from this project: https://github.com/PRQL/prql-query and they all worked fine.

Closes #468

The idea is to keep the numeric dtypes only using Int64 for integers or
Float64 for floats.
@philss philss requested a review from josevalim January 12, 2023 06:09
Copy link

@ahnlabb ahnlabb left a comment

Choose a reason for hiding this comment

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

This is great @philss! The change is still missing for binary data however:

https://github.com/elixir-nx/explorer/blob/25f31bb7397c8eb41f52e81ad6365e0218a43993/native/explorer/src/dataframe/io.rs#L270-L275

Perhaps future misses like that could be avoided by increasing code sharing between the functions a bit?

Comment on lines 374 to 380
.with_columns(columns)
.with_projection(projection)
.finish()?;
Ok(ExDataFrame::new(df))

let normalized_df = normalize_numeric_dtypes(&mut df)?;

Ok(ExDataFrame::new(normalized_df))
Copy link

@ahnlabb ahnlabb Jan 12, 2023

Choose a reason for hiding this comment

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

Could this part be factored out into a function by using the SerReader trait so that future changes to the import through of SerReader do not miss any of the functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! I'm not sure if I understood correctly, but I added a function to abstract the "finish" process, which is more clear now. Please check again :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm merging this in order to add to the new release. Please fell free to open a PR if you think this can be improved.


let normalized_df = crate::dataframe::normalize_numeric_dtypes(&mut df)?;

Ok(ExDataFrame::new(normalized_df))
Copy link
Member

Choose a reason for hiding this comment

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

Doing this change here is too late because all operations in the lazy frame would then act on i32, u32 and so on. We also need to do them immediately after reading the file/binary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. I don't know yet how to apply this change for a LazyFrame, so I decided to revert and keep it just for the eager frame. I think I'm going to open an issue for that and tackle after the release. WDYT?

@philss
Copy link
Member Author

philss commented Jan 12, 2023

This is great @philss! The change is still missing for binary data however:

I forgot the most important 😅
It is fixed now.

@philss philss merged commit f8f0226 into elixir-explorer:main Jan 12, 2023
@philss philss deleted the ps-normalize-numeric-dtypes-for-io-ops branch January 12, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for more datatypes
3 participants