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

Update parquet::basic::LogicalType to be more idomatic #1612

Merged
merged 14 commits into from Apr 24, 2022

Conversation

tfeda
Copy link
Contributor

@tfeda tfeda commented Apr 23, 2022

Which issue does this PR close?

Closes #1554.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

See #1554. I can provide more detail if needed, but nothing really goes beyond the scope of the issue.

@github-actions github-actions bot added parquet Changes to the parquet crate parquet-derive labels Apr 23, 2022
@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2022

Codecov Report

Merging #1612 (17494f4) into master (4e22b89) will decrease coverage by 0.06%.
The diff coverage is 66.54%.

@@            Coverage Diff             @@
##           master    #1612      +/-   ##
==========================================
- Coverage   82.95%   82.89%   -0.07%     
==========================================
  Files         193      193              
  Lines       55439    55464      +25     
==========================================
- Hits        45992    45978      -14     
- Misses       9447     9486      +39     
Impacted Files Coverage Δ
parquet_derive/src/parquet_field.rs 66.43% <0.00%> (+0.22%) ⬆️
parquet/src/schema/types.rs 85.68% <53.84%> (-0.04%) ⬇️
parquet/src/arrow/schema.rs 85.78% <65.00%> (-0.31%) ⬇️
parquet/src/schema/printer.rs 67.09% <69.76%> (-1.48%) ⬇️
parquet/src/basic.rs 91.49% <71.42%> (-2.90%) ⬇️
parquet/src/schema/parser.rs 84.98% <77.27%> (-0.13%) ⬇️
parquet/src/column/writer.rs 92.42% <100.00%> (ø)
parquet/src/file/writer.rs 93.30% <100.00%> (ø)
arrow/src/datatypes/datatype.rs 66.40% <0.00%> (-0.40%) ⬇️
parquet/src/encodings/encoding.rs 93.37% <0.00%> (-0.19%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e22b89...17494f4. Read the comment docs.

Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

Thanks for this, LGTM 👍

@@ -678,20 +678,20 @@ impl ParquetTypeConverter<'_> {
(32, false) => Ok(DataType::UInt32),
_ => Err(ArrowError(format!(
"Cannot create INT32 physical type from {:?}",
t
self.schema.get_basic_info().logical_type(),
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use t @ LogicalType::Integer { ... } in the match expression, so that you can use t here

Copy link
Contributor Author

@tfeda tfeda Apr 23, 2022

Choose a reason for hiding this comment

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

I've spent some time looking into this. This syntax causes t to be evaluated as a LogicalType rather than a LogicalType::Integer. It then can't use it for match (t.bit_width, t.is_signed) . I also tried t @ LogicalType::Integer { bit_width, is_signed }, but then I run into borrow issues. Is there some order-of-op trick I'm missing?

Copy link
Contributor

@tustvold tustvold Apr 23, 2022

Choose a reason for hiding this comment

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

Does this help - https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ec783c91c37289091cce85107031b3df

Btw you can drop the "ref" if you make LogicalType implement Copy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhhh I missed the ref, thanks. Adding a ref seemed better than deriving Copy for LogicalType, TimeUnit, MilliSeconds, etc.

@tustvold tustvold merged commit 5374289 into apache:master Apr 24, 2022
@tustvold
Copy link
Contributor

Thanks again for this 👍

@alamb alamb added the api-change Changes to the arrow API label Apr 27, 2022
@alamb alamb changed the title Update datatypes in parquet::basic::LogicalType Update parquet::basic::LogicalType to be more idomatic Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API parquet Changes to the parquet crate parquet-derive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ergonomics of parquet::basic::LogicalType
4 participants