Skip to content

Commit

Permalink
Fix conformance test name generation for mixed camel-/snake-case (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr authored Jan 10, 2025
1 parent b965c45 commit 1b19d11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions partiql-conformance-test-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Inflector = "0.11"
miette = { version = "7", features = ["fancy"] }
thiserror = "1.0"
quote = "1"
itertools = "0.14"
26 changes: 25 additions & 1 deletion partiql-conformance-test-generator/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use inflector::Inflector;
use itertools::Itertools;
use quote::__private::TokenStream;

pub trait Escaper {
Expand All @@ -13,10 +14,20 @@ pub trait Escaper {
}

fn escape_str(s: &str) -> String {
let snake_case: String = s
.split(|c: char| c.is_ascii_punctuation() || c.is_whitespace())
.filter(|s| !s.is_empty())
.filter(|s| {
!s.chars()
.all(|c| c.is_ascii_punctuation() || c.is_whitespace())
})
.map(|s| s.to_snake_case())
.filter(|s| !s.is_empty())
.join("_");

match s.chars().next() {
None => "_".to_string(),
Some(c) => {
let snake_case = s.to_lowercase().to_snake_case();
if c.is_numeric() {
format!("_{}", snake_case)
} else {
Expand Down Expand Up @@ -95,4 +106,17 @@ mod test {
"example_7_null_and_missing_coercion_1"
);
}

#[test]
fn snake_case_uppercase_names_without_spaces() {
assert_eq!(
"cast to int invalid target type{value:\"`(1 2)`\",target:\"SEXP\"}".escape_path(),
"cast_to_int_invalid_target_type_value_1_2_target_sexp"
);
}

#[test]
fn snake_case_camelcased() {
assert_eq!("rangeOverSexp".escape_path(), "range_over_sexp");
}
}

1 comment on commit 1b19d11

@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: 1b19d11 Previous: b965c45 Ratio
arith_agg-avg 766648 ns/iter (± 4238) 766247 ns/iter (± 18752) 1.00
arith_agg-avg_distinct 861535 ns/iter (± 1550) 854173 ns/iter (± 21056) 1.01
arith_agg-count 815139 ns/iter (± 12287) 810955 ns/iter (± 23860) 1.01
arith_agg-count_distinct 854865 ns/iter (± 1904) 849671 ns/iter (± 10308) 1.01
arith_agg-min 819999 ns/iter (± 2348) 818696 ns/iter (± 2282) 1.00
arith_agg-min_distinct 857922 ns/iter (± 1733) 853340 ns/iter (± 5638) 1.01
arith_agg-max 825238 ns/iter (± 3604) 822208 ns/iter (± 2273) 1.00
arith_agg-max_distinct 866332 ns/iter (± 2757) 859653 ns/iter (± 4318) 1.01
arith_agg-sum 820739 ns/iter (± 3041) 818895 ns/iter (± 4759) 1.00
arith_agg-sum_distinct 864789 ns/iter (± 2361) 856024 ns/iter (± 2834) 1.01
arith_agg-avg-count-min-max-sum 972890 ns/iter (± 3096) 972679 ns/iter (± 12670) 1.00
arith_agg-avg-count-min-max-sum-group_by 1243160 ns/iter (± 11355) 1233558 ns/iter (± 22133) 1.01
arith_agg-avg-count-min-max-sum-group_by-group_as 1849620 ns/iter (± 10064) 1845900 ns/iter (± 61781) 1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct 1186602 ns/iter (± 4488) 1172846 ns/iter (± 38661) 1.01
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by 1467134 ns/iter (± 7227) 1432505 ns/iter (± 16806) 1.02
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as 2067090 ns/iter (± 14009) 2049718 ns/iter (± 8971) 1.01
parse-1 6571 ns/iter (± 13) 6301 ns/iter (± 174) 1.04
parse-15 54306 ns/iter (± 232) 49139 ns/iter (± 153) 1.11
parse-30 105393 ns/iter (± 244) 99922 ns/iter (± 375) 1.05
compile-1 4193 ns/iter (± 11) 4242 ns/iter (± 25) 0.99
compile-15 30585 ns/iter (± 134) 30918 ns/iter (± 179) 0.99
compile-30 62898 ns/iter (± 408) 63390 ns/iter (± 497) 0.99
plan-1 72782 ns/iter (± 197) 72590 ns/iter (± 511) 1.00
plan-15 1130914 ns/iter (± 79606) 1132456 ns/iter (± 6187) 1.00
plan-30 2264952 ns/iter (± 11751) 2278769 ns/iter (± 9474) 0.99
eval-1 11877539 ns/iter (± 51184) 12654517 ns/iter (± 492500) 0.94
eval-15 75970932 ns/iter (± 3530087) 77595784 ns/iter (± 384744) 0.98
eval-30 145051263 ns/iter (± 959139) 147319643 ns/iter (± 790643) 0.98
join 10004 ns/iter (± 453) 10121 ns/iter (± 68) 0.99
simple 2486 ns/iter (± 14) 2532 ns/iter (± 14) 0.98
simple-no 459 ns/iter (± 1) 499 ns/iter (± 1) 0.92
numbers 48 ns/iter (± 0) 48 ns/iter (± 0) 1
parse-simple 884 ns/iter (± 2) 842 ns/iter (± 4) 1.05
parse-ion 2611 ns/iter (± 7) 2730 ns/iter (± 6) 0.96
parse-group 7809 ns/iter (± 72) 7899 ns/iter (± 89) 0.99
parse-complex 20394 ns/iter (± 60) 20983 ns/iter (± 114) 0.97
parse-complex-fexpr 27578 ns/iter (± 158) 27810 ns/iter (± 158) 0.99

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

Please sign in to comment.