Skip to content

Conversation

@superserious-dev
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Follow-up from the previous PR that added decoders for primitive values.

What changes are included in this PR?

  • Verifies that an error is emitted if a decoder does not have enough bytes to consume
  • Ensures that decimal scale values can't exceed the maximum from the spec + tests to verify

@github-actions github-actions bot added the parquet Changes to the parquet crate label Jun 25, 2025
[dependencies]
arrow-schema = { workspace = true }
chrono = { workspace = true }
paste = { version = "1.0" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used for writing the decoder test macros. This is already a dependency in the parquet crate, so bringing it into parquet-variant.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is only used in tests, perhaps we can move it to dev-dependencies

[dev-dependencies]
paste = { version = "1.0" }

use super::*;
use paste::paste;

mod integer {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created macros and grouped similar tests together in order to reduce some of the boilerplate test code.


// Makes the code a bit more readable
pub(crate) const VARIANT_VALUE_HEADER_BYTES: usize = 1;
pub(crate) const DECIMAL_MAX_SCALE: u8 = 38;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the spec, all the decimal variants have a max scale of 38.

Copy link
Contributor

Choose a reason for hiding this comment

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

#7779 does not include any decoder tests though

I think we could potentially avoid checking the scale/precision for decimals in the decoder and let the higher level validation check them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I removed the extra scale validation.

@superserious-dev superserious-dev changed the title Variant] Add negative tests for reading invalid primitive variant values [Variant] Add negative tests for reading invalid primitive variant values Jun 25, 2025
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 @superserious-dev -- I think this is a very nice improvement. I have some suggestions on how to improve the testing, but I don't think they are required

I suspect there will be some conflicts to resolve after I merge #7776 which I am about to do

[dependencies]
arrow-schema = { workspace = true }
chrono = { workspace = true }
paste = { version = "1.0" }
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is only used in tests, perhaps we can move it to dev-dependencies

[dev-dependencies]
paste = { version = "1.0" }


// Makes the code a bit more readable
pub(crate) const VARIANT_VALUE_HEADER_BYTES: usize = 1;
pub(crate) const DECIMAL_MAX_SCALE: u8 = 38;
Copy link
Contributor

Choose a reason for hiding this comment

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

#7779 does not include any decoder tests though

I think we could potentially avoid checking the scale/precision for decimals in the decoder and let the higher level validation check them

@alamb
Copy link
Contributor

alamb commented Jun 25, 2025

FYI @Weijun-H @mkarbo @friendlymatthew

@alamb
Copy link
Contributor

alamb commented Jun 29, 2025

Thanks again @superserious-dev

@alamb alamb merged commit c1a57cb into apache:main Jun 29, 2025
13 checks passed
@superserious-dev superserious-dev deleted the negative-decoder-tests branch June 29, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Variant] Add negative tests for reading invalid primitive variant values

2 participants