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 metas to PartiQL Common #488

Merged
merged 9 commits into from
Aug 17, 2024
Merged

Add metas to PartiQL Common #488

merged 9 commits into from
Aug 17, 2024

Conversation

am357
Copy link
Contributor

@am357 am357 commented Aug 16, 2024

Description of changes:

Adds an implementation for storing metadata for PartiQL objects. Currently, the implementation does not include any traits. It introduces PartiqlMetadata and PartiqlMetaValue structures:

        let foo_val = PartiqlMetaValue::String("foo".to_string());
        let i64_val = PartiqlMetaValue::Int64(2);

        let expected_vec_val = vec![foo_val, i64_val];
        let expected_bool_val = true;
        let expected_int_val = 2;
        let expected_float_val = 2.5;
        let expected_str_val = "foo";

        let mut expected_map = PartiqlMetadata::new();
        expected_map.insert("bool value", expected_bool_val.into());
        expected_map.insert("integer value", expected_int_val.into());

        let mut metas = PartiqlMetadata::new();
        metas.insert("vec value", expected_vec_val.clone().into());
        metas.insert("bool value", expected_bool_val.into());
        metas.insert("integer value", expected_int_val.into());
        metas.insert("float value", expected_float_val.into());
        metas.insert("string value", expected_str_val.into());
        metas.insert("map value", expected_map.clone().into());

        let vec_val = metas.vec_value("vec value").expect("vec meta value");
        let bool_val = metas.bool_value("bool value").expect("bool meta value");
        let int_val = metas.i32_value("integer value").expect("i32 meta value");
        let float_val = metas.f64_value("float value").expect("f64 meta value");
        let string_val = metas.string_value("string value").expect("string meta value");
        let map_val = metas.map_value("map value").expect("map meta value");

        assert_eq!(vec_val, expected_vec_val.clone());
        assert_eq!(bool_val, expected_bool_val.clone());
        assert_eq!(int_val, expected_int_val.clone());
        assert_eq!(float_val, expected_float_val.clone());
        assert_eq!(string_val, expected_str_val);
        assert_eq!(map_val, expected_map.clone());

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This PR
- adds `NodeId` to `StaticType`.
- makes `AutoNodeIdGenerator` thread-safe
- adds `PartiqlShapeBuilder` and moves some `PartiqlShape` APIs to it; this is to be able to generate unique `NodeId`s for a `PartiqlShape` that includes static types that themselves can include other static types.
- adds a static thread safe `shape_builder` function that provides a convenient way for using `PartiqlShapeBuilder` for creating new shapes.
- prepends existing type macros with `type` such as `type_int!` to make macro names more friendly.
- removes `const` PartiQL types under `partiql-types` in favor of `PartiqlShapeBuilder`.
Adds an implementation for storing metadata for PartiQL objects. Currently, the implementation does not include any traits. It introduces `PartiqlMetadata` and `PartiqlMetaValue` structures:

```rust
        let foo_val = PartiqlMetaValue::String("foo".to_string());
        let i64_val = PartiqlMetaValue::Int64(2);

        let expected_vec_val = vec![foo_val, i64_val];
        let expected_bool_val = true;
        let expected_int_val = 2;
        let expected_float_val = 2.5;
        let expected_str_val = "foo";

        let mut expected_map = PartiqlMetadata::new();
        expected_map.insert("bool value", expected_bool_val.into());
        expected_map.insert("integer value", expected_int_val.into());

        let mut metas = PartiqlMetadata::new();
        metas.insert("vec value", expected_vec_val.clone().into());
        metas.insert("bool value", expected_bool_val.into());
        metas.insert("integer value", expected_int_val.into());
        metas.insert("float value", expected_float_val.into());
        metas.insert("string value", expected_str_val.into());
        metas.insert("map value", expected_map.clone().into());

        let vec_val = metas.vec_value("vec value").expect("vec meta value");
        let bool_val = metas.bool_value("bool value").expect("bool meta value");
        let int_val = metas.i32_value("integer value").expect("i32 meta value");
        let float_val = metas.f64_value("float value").expect("f64 meta value");
        let string_val = metas.string_value("string value").expect("string meta value");
        let map_val = metas.map_value("map value").expect("map meta value");

        assert_eq!(vec_val, expected_vec_val.clone());
        assert_eq!(bool_val, expected_bool_val.clone());
        assert_eq!(int_val, expected_int_val.clone());
        assert_eq!(float_val, expected_float_val.clone());
        assert_eq!(string_val, expected_str_val);
        assert_eq!(map_val, expected_map.clone());
```
Copy link

github-actions bot commented Aug 16, 2024

Conformance comparison report

Base (7203852) 1273b62 +/-
% Passing 90.35% 90.35% 0.00%
✅ Passing 5731 5731 0
❌ Failing 612 612 0
🔶 Ignored 0 0 0
Total Tests 6343 6343 0

Number passing in both: 5731

Number failing in both: 612

Number passing in Base (7203852) but now fail: 0

Number failing in Base (7203852) but now pass: 0

@am357 am357 marked this pull request as ready for review August 16, 2024 21:50
@am357 am357 requested a review from jpschorr August 16, 2024 21:50
partiql-common/src/metadata.rs Show resolved Hide resolved
partiql-common/src/metadata.rs Show resolved Hide resolved
Copy link

codecov bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 46.76617% with 107 lines in your changes missing coverage. Please review.

Project coverage is 80.61%. Comparing base (7203852) to head (42816dd).
Report is 1 commits behind head on main.

Files Patch % Lines
partiql-common/src/metadata.rs 46.76% 107 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #488      +/-   ##
==========================================
- Coverage   80.98%   80.61%   -0.37%     
==========================================
  Files          69       70       +1     
  Lines       18796    18997     +201     
  Branches    18796    18997     +201     
==========================================
+ Hits        15221    15315      +94     
- Misses       3131     3238     +107     
  Partials      444      444              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@am357 am357 merged commit 843d3ee into main Aug 17, 2024
17 checks passed
@am357 am357 deleted the feat-metas branch August 17, 2024 01: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