Skip to content

Commit

Permalink
Fix DDL output for Array and Bag types. (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr authored Jan 25, 2025
1 parent 4792d1c commit b056bcf
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions extension/partiql-extension-ddl/src/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,13 @@ impl PartiqlBasicDdlEncoder {

fn write_type_bag(&self, type_bag: &BagType) -> ShapeDdlEncodeResult<String> {
Ok(format!(
"type_bag<{}>",
"BAG<{}>",
self.write_shape(type_bag.element_type())?
))
}

fn write_type_array(&self, arr: &ArrayType) -> ShapeDdlEncodeResult<String> {
Ok(format!(
"type_array<{}>",
self.write_shape(arr.element_type())?
))
Ok(format!("ARRAY<{}>", self.write_shape(arr.element_type())?))
}

fn write_struct(&self, strct: &StructType) -> ShapeDdlEncodeResult<String> {
Expand Down Expand Up @@ -260,12 +257,12 @@ mod tests {
type_struct![bld, IndexSet::from([fields, StructConstraint::Open(false)])]
];

let expected_compact = r#""employee_id" TINYINT,"full_name" VARCHAR,"salary" DECIMAL(8, 2),"details" STRUCT<"a": UNION<DECIMAL(5, 4),TINYINT>,"b": type_array<VARCHAR>,"c": DOUBLE>,"dependents" type_array<VARCHAR>"#;
let expected_compact = r#""employee_id" TINYINT,"full_name" VARCHAR,"salary" DECIMAL(8, 2),"details" STRUCT<"a": UNION<DECIMAL(5, 4),TINYINT>,"b": ARRAY<VARCHAR>,"c": DOUBLE>,"dependents" ARRAY<VARCHAR>"#;
let expected_pretty = r#""employee_id" TINYINT,
"full_name" VARCHAR,
"salary" DECIMAL(8, 2),
"details" STRUCT<"a": UNION<DECIMAL(5, 4),TINYINT>,"b": type_array<VARCHAR>,"c": DOUBLE>,
"dependents" type_array<VARCHAR>"#;
"details" STRUCT<"a": UNION<DECIMAL(5, 4),TINYINT>,"b": ARRAY<VARCHAR>,"c": DOUBLE>,
"dependents" ARRAY<VARCHAR>"#;

let ddl_compact = PartiqlBasicDdlEncoder::new(DdlFormat::Compact);
assert_eq!(ddl_compact.ddl(&ty).expect("write shape"), expected_compact);
Expand Down

1 comment on commit b056bcf

@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: b056bcf Previous: 4792d1c Ratio
arith_agg-avg 757318 ns/iter (± 16002) 799180 ns/iter (± 10763) 0.95
arith_agg-avg_distinct 844086 ns/iter (± 9443) 882685 ns/iter (± 2463) 0.96
arith_agg-count 807409 ns/iter (± 42589) 854073 ns/iter (± 16094) 0.95
arith_agg-count_distinct 836927 ns/iter (± 12277) 878784 ns/iter (± 3765) 0.95
arith_agg-min 808410 ns/iter (± 6995) 856840 ns/iter (± 5485) 0.94
arith_agg-min_distinct 840825 ns/iter (± 3734) 882859 ns/iter (± 3213) 0.95
arith_agg-max 815584 ns/iter (± 4834) 860209 ns/iter (± 4433) 0.95
arith_agg-max_distinct 850107 ns/iter (± 3559) 888296 ns/iter (± 2830) 0.96
arith_agg-sum 812224 ns/iter (± 4057) 859308 ns/iter (± 10047) 0.95
arith_agg-sum_distinct 842331 ns/iter (± 14878) 880882 ns/iter (± 9083) 0.96
arith_agg-avg-count-min-max-sum 979063 ns/iter (± 12065) 1022309 ns/iter (± 7418) 0.96
arith_agg-avg-count-min-max-sum-group_by 1254376 ns/iter (± 7362) 1299778 ns/iter (± 9948) 0.97
arith_agg-avg-count-min-max-sum-group_by-group_as 1858137 ns/iter (± 18285) 1935932 ns/iter (± 9387) 0.96
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct 1185559 ns/iter (± 23163) 1235222 ns/iter (± 11077) 0.96
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by 1455563 ns/iter (± 19682) 1529091 ns/iter (± 10680) 0.95
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as 2009789 ns/iter (± 8262) 2149568 ns/iter (± 16375) 0.93
parse-1 5508 ns/iter (± 13) 5441 ns/iter (± 152) 1.01
parse-15 46937 ns/iter (± 214) 46367 ns/iter (± 159) 1.01
parse-30 91095 ns/iter (± 317) 90639 ns/iter (± 191) 1.01
compile-1 4314 ns/iter (± 127) 4295 ns/iter (± 109) 1.00
compile-15 31291 ns/iter (± 164) 30685 ns/iter (± 129) 1.02
compile-30 64400 ns/iter (± 451) 64239 ns/iter (± 2548) 1.00
plan-1 70814 ns/iter (± 595) 70894 ns/iter (± 387) 1.00
plan-15 1101201 ns/iter (± 27461) 1105696 ns/iter (± 10190) 1.00
plan-30 2112687 ns/iter (± 31704) 2213383 ns/iter (± 25125) 0.95
eval-1 12113412 ns/iter (± 159946) 12809424 ns/iter (± 223288) 0.95
eval-15 78669131 ns/iter (± 244003) 79139260 ns/iter (± 1088736) 0.99
eval-30 150325118 ns/iter (± 481405) 149902007 ns/iter (± 740154) 1.00
join 9754 ns/iter (± 410) 9971 ns/iter (± 49) 0.98
simple 2514 ns/iter (± 8) 2565 ns/iter (± 10) 0.98
simple-no 505 ns/iter (± 4) 465 ns/iter (± 1) 1.09
numbers 57 ns/iter (± 0) 57 ns/iter (± 0) 1
parse-simple 689 ns/iter (± 1) 736 ns/iter (± 3) 0.94
parse-ion 2324 ns/iter (± 18) 2304 ns/iter (± 24) 1.01
parse-group 7152 ns/iter (± 30) 6892 ns/iter (± 21) 1.04
parse-complex 18744 ns/iter (± 181) 18554 ns/iter (± 93) 1.01
parse-complex-fexpr 26076 ns/iter (± 187) 25476 ns/iter (± 203) 1.02

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

Please sign in to comment.