Skip to content

Commit

Permalink
Add metas to PartiQL Common (#488)
Browse files Browse the repository at this point in the history
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());
```
  • Loading branch information
am357 authored Aug 17, 2024
1 parent 7203852 commit 843d3ee
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- partiql-ast: fixed pretty-printing of `PIVOT`
- partiql-ast: improved pretty-printing of `CASE` and various clauses
-

### Added
- Added `partiql-common`.
- Added `NodeId` to `StaticType`.
- *BREAKING* Added thread-safe `PartiqlShapeBuilder` and automatic `NodeId` generation for the `StaticType`.
- Added a static thread safe `shape_builder` function that provides a convenient way for using `PartiqlShapeBuilder` for creating new shapes.
- Added `partiql_common::meta::PartiqlMetadata`

### Removed
- *BREAKING* Removed `partiql-source-map`.
Expand Down
1 change: 1 addition & 0 deletions partiql-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bench = false
indexmap = "2.2"
pretty = "0.12"
serde = { version = "1.*", features = ["derive"], optional = true }
rust_decimal = { version = "1.25.0", default-features = false, features = ["std"] }
smallvec = { version = "1.*" }
thiserror = "1.0"

Expand Down
1 change: 1 addition & 0 deletions partiql-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(rust_2018_idioms)]
#![deny(clippy::all)]
pub mod metadata;
pub mod node;
pub mod syntax;
Loading

1 comment on commit 843d3ee

@github-actions
Copy link

Choose a reason for hiding this comment

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

PartiQL (rust) Benchmark

Benchmark suite Current: 843d3ee Previous: 7203852 Ratio
arith_agg-avg 759774 ns/iter (± 16111) 761989 ns/iter (± 2584) 1.00
arith_agg-avg_distinct 851602 ns/iter (± 1675) 856629 ns/iter (± 2352) 0.99
arith_agg-count 809485 ns/iter (± 31348) 813071 ns/iter (± 16235) 1.00
arith_agg-count_distinct 850096 ns/iter (± 2714) 849796 ns/iter (± 3499) 1.00
arith_agg-min 813205 ns/iter (± 2203) 817287 ns/iter (± 12938) 1.00
arith_agg-min_distinct 851965 ns/iter (± 18121) 854925 ns/iter (± 1637) 1.00
arith_agg-max 832033 ns/iter (± 4653) 828374 ns/iter (± 15165) 1.00
arith_agg-max_distinct 861344 ns/iter (± 4073) 863610 ns/iter (± 3061) 1.00
arith_agg-sum 815417 ns/iter (± 2226) 817340 ns/iter (± 4491) 1.00
arith_agg-sum_distinct 855702 ns/iter (± 2666) 857382 ns/iter (± 5483) 1.00
arith_agg-avg-count-min-max-sum 957159 ns/iter (± 4904) 962352 ns/iter (± 2579) 0.99
arith_agg-avg-count-min-max-sum-group_by 1213008 ns/iter (± 15351) 1184994 ns/iter (± 37004) 1.02
arith_agg-avg-count-min-max-sum-group_by-group_as 1814083 ns/iter (± 5194) 1802258 ns/iter (± 23102) 1.01
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct 1263534 ns/iter (± 15338) 1258025 ns/iter (± 50557) 1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by 1528754 ns/iter (± 12065) 1517674 ns/iter (± 8829) 1.01
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as 2132246 ns/iter (± 21947) 2111719 ns/iter (± 14340) 1.01
parse-1 5994 ns/iter (± 90) 5949 ns/iter (± 77) 1.01
parse-15 52257 ns/iter (± 560) 49885 ns/iter (± 225) 1.05
parse-30 101862 ns/iter (± 335) 100431 ns/iter (± 280) 1.01
compile-1 4264 ns/iter (± 14) 4345 ns/iter (± 30) 0.98
compile-15 32659 ns/iter (± 226) 33556 ns/iter (± 98) 0.97
compile-30 69444 ns/iter (± 1090) 69779 ns/iter (± 296) 1.00
plan-1 67184 ns/iter (± 484) 67795 ns/iter (± 269) 0.99
plan-15 1052870 ns/iter (± 8363) 1047210 ns/iter (± 9506) 1.01
plan-30 2111762 ns/iter (± 8350) 2098549 ns/iter (± 5644) 1.01
eval-1 12633251 ns/iter (± 38348) 12755601 ns/iter (± 45848) 0.99
eval-15 85671873 ns/iter (± 809621) 86481769 ns/iter (± 851403) 0.99
eval-30 164703537 ns/iter (± 499568) 166749677 ns/iter (± 551437) 0.99
join 9731 ns/iter (± 39) 9733 ns/iter (± 210) 1.00
simple 2489 ns/iter (± 7) 2478 ns/iter (± 76) 1.00
simple-no 432 ns/iter (± 1) 435 ns/iter (± 1) 0.99
numbers 57 ns/iter (± 0) 57 ns/iter (± 0) 1
parse-simple 847 ns/iter (± 3) 901 ns/iter (± 4) 0.94
parse-ion 2525 ns/iter (± 9) 2510 ns/iter (± 26) 1.01
parse-group 7762 ns/iter (± 504) 7341 ns/iter (± 55) 1.06
parse-complex 19915 ns/iter (± 679) 19828 ns/iter (± 92) 1.00
parse-complex-fexpr 27020 ns/iter (± 208) 27149 ns/iter (± 181) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.