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 proptest strategies for generating Dimension, a bunch of Debug impls, and even some arrow stuff #15

Merged
merged 13 commits into from
Mar 20, 2024

Conversation

rroelke
Copy link
Member

@rroelke rroelke commented Mar 20, 2024

This is what fell out of me working on the Arrow schema conversion functions. I wanted to do PBT for them, but that means we have to have strategies to generate Schema, which requires Domain, which requires Dimension, and maybe more!

So this pull request ends up being mostly test stuff with a little bit of arrow.

A few notable things:

  • the macro fn_typed which emulates the same function we have in C++
  • the LifetimeStrategy struct which works around using fn_typed in a strategy and also having a non-static lifetime due to needing the &'ctx tiledb::context::Context
  • the Debug impls I added use serde_json to format their results

@rroelke rroelke requested a review from davisp March 20, 2024 20:20
Copy link
Collaborator

@davisp davisp left a comment

Choose a reason for hiding this comment

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

Awesome work. Most of my comments were just style related. Overall its great though. The only thing I'd say to change is copying your PR comment next to that big macro definition since it really does help clarify what's going on there.

@@ -0,0 +1,65 @@
use tiledb::context::Context as TileDBContext;
use tiledb::Result as TileDBResult;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably get a PR up so that all of our important things are importable wiht a statement like:

use tiledb::{TileDBArray, TileDBContext, TileDBQuery, TileDBResult};

proptest!(|(attr in tiledb_test::attribute::arbitrary(&c))| {
if let Some(arrow_field) = arrow_field(&attr).expect("Error reading tiledb attribute") {
assert_eq!(attr.name()?, *arrow_field.name());
assert!(crate::datatype::is_same_physical_type(&attr.datatype()?, arrow_field.data_type()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hurms. Still more wonky lack of indentation. Perhaps this is because of the enclosing macro? I've verified locally that this is what rustfmt gives.

Copy link
Member Author

Choose a reason for hiding this comment

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

It definitely seems like rustfmt doesn't know what to do with macros

@rroelke rroelke merged commit 778144d into main Mar 20, 2024
1 check passed
@rroelke rroelke deleted the rr/proptest-dimension-arbitrary branch March 20, 2024 21:19
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.

2 participants