Skip to content

Commit

Permalink
Boxed Ion final cleanup and tests. (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr authored Feb 6, 2025
1 parent 50b55e3 commit e47058e
Show file tree
Hide file tree
Showing 35 changed files with 13,283 additions and 188 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "partiql-conformance-tests/partiql-tests"]
path = partiql-conformance-tests/partiql-tests
url = https://github.com/partiql/partiql-tests.git
[submodule "extension/partiql-extension-ion/resources/ion-tests"]
path = extension/partiql-extension-ion/resources/ion-tests
url = https://github.com/amazon-ion/ion-tests/
3 changes: 2 additions & 1 deletion extension/partiql-extension-ion-functions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ thiserror = "1.0"
delegate = "0.13"
zstd = "0.13"
flate2 = "1.0"
insta = "1"

[dev-dependencies]
partiql-parser = { path = "../../partiql-parser", version = "0.11.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.11.*" }
partiql-logical-planner = { path = "../../partiql-logical-planner", version = "0.11.*" }
partiql-eval = { path = "../../partiql-eval", version = "0.11.*" }

insta = "1"

[features]
default = []
2 changes: 1 addition & 1 deletion extension/partiql-extension-ion-functions/src/scan_ion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn parse_ion_file<'a>(path: &str) -> IonTableExprResult<'a> {
}

fn parse_ion_buff<'a, I: 'a + Read + 'static>(input: BufReader<I>) -> IonTableExprResult<'a> {
let iter = BoxedIonType {}.construct_buffered(input)?.try_into_iter()?;
let iter = BoxedIonType {}.stream_from_read(input)?.try_into_iter()?;
let iter = iter.map(|value| match value {
Ok(v) => Ok(v.into_value()),
Err(e) => Err(match e {
Expand Down
2 changes: 1 addition & 1 deletion extension/partiql-extension-ion-functions/tests/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn ion_read_select_distinct(file: &str) {
macro_rules! ion {
($x:expr) => {
partiql_extension_ion::boxed_ion::BoxedIonType {}
.construct_str($x)
.value_from_str($x)
.expect("boxed ion construct")
.into_value()
};
Expand Down
2 changes: 2 additions & 0 deletions extension/partiql-extension-ion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ delegate = "0.13"
peekmore = "1.3"

[dev-dependencies]
insta = "1"
walkdir = "2.5"

[features]
default = []
Expand Down
1 change: 1 addition & 0 deletions extension/partiql-extension-ion/resources/ion-tests
Submodule ion-tests added at a22bf4
221 changes: 221 additions & 0 deletions extension/partiql-extension-ion/resources/test/test.ion
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
///////
// These values taken from https://amazon-ion.github.io/ion-docs/docs/spec.html
//////


null

nan
-inf
+inf

null.null // Identical to unadorned null
null.bool
null.int
null.float
null.decimal
null.timestamp
null.string
null.symbol
null.blob
null.clob
null.struct
null.list
null.sexp



null // The type is null
'null' // The type is symbol
null.list // The type is list
'null.int' // The type is symbol


null.bool
true
false


null.int // A null int value
0 // Zero. Surprise!
-0 // ...the same value with a minus sign
123 // A normal int
-123 // Another negative int
0xBeef // An int denoted in hexadecimal
0b0101 // An int denoted in binary
1_2_3 // An int with underscores
0xFA_CE // An int denoted in hexadecimal with underscores
0b10_10_10 // An int denoted in binary with underscores

_1 // A symbol (ints cannot start with underscores)


null.decimal // A null decimal value
null.float // A null float value

0.123 // Type is decimal
-0.12e4 // Type is float
-0.12d4 // Type is decimal

0E0 // Zero as float
0D0 // Zero as decimal
0. // ...the same decimal value with different notation
-0e0 // Negative zero float (distinct from positive zero)
-0d0 // Negative zero decimal (distinct from positive zero)
-0. // ...the same decimal value with different notation
-0d-1 // Decimal maintains precision: -0. != -0.0

123_456.789_012 // Decimal with underscores


null.timestamp // A null timestamp value

2007-02-23T12:14Z // Seconds are optional, but local offset is not
2007-02-23T12:14:33.079-08:00 // A timestamp with millisecond precision and PST local time
2007-02-23T20:14:33.079Z // The same instant in UTC ("zero" or "zulu")
2007-02-23T20:14:33.079+00:00 // The same instant, with explicit local offset
2007-02-23T20:14:33.079-00:00 // The same instant, with unknown local offset

2007-01-01T00:00-00:00 // Happy New Year in UTC, unknown local offset
2007-01-01 // The same instant, with days precision, unknown local offset
2007-01-01T // The same value, different syntax.
2007-01T // The same instant, with months precision, unknown local offset
2007T // The same instant, with years precision, unknown local offset

2007-02-23 // A day, unknown local offset
2007-02-23T00:00Z // The same instant, but more precise and in UTC
2007-02-23T00:00+00:00 // An equivalent format for the same value
2007-02-23T00:00:00-00:00 // The same instant, with seconds precision

2007 // Not a timestamp, but an int

2000T // January 1st 2000, year precision, unknown local offset
2000-01-01T00:00:00Z // January 1st 2000, second precision, UTC
2000-01-01T00:00:00.000Z // January 1st 2000, millisecond precision, UTC
2000-01-01T00:00:00.000-00:00 // January 1st 2000, millisecond precision, negative zero local offset


null.string // A null string value
"" // An empty string value
" my string " // A normal string
"\"" // Contains one double-quote character
"\uABCD" // Contains one unicode character

xml::"<e a='v'>c</e>" // String with type annotation 'xml'




( '''hello ''' // Sexp with one element
'''world!''' )

("hello world!") // The exact same sexp value

// This Ion value is a string containing three newlines. The serialized
// form's first newline is escaped into nothingness.
'''\
The first line of the string.
This is the second line of the string,
and this is the third line.
'''


null.symbol // A null symbol value
'myVar2' // A symbol
myVar2 // The same symbol
myvar2 // A different symbol
'hi ho' // Symbol requiring quotes
'\'ahoy\'' // A symbol with embedded quotes
'' // The empty symbol




( 'x' '+' 'y' ) // S-expression with three symbols
( x + y ) // The same three symbols
(x+y) // The same three symbols
(a==b&&c==d) // S-expression with seven symbols




// A null blob value
null.blob

// A valid blob value with zero padding characters.
{{
+AB/
}}

// A valid blob value with one required padding character.
{{ VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE= }}

// A valid blob value with two required padding characters.
{{ dHdvIHBhZGRpbmcgY2hhcmFjdGVycw== }}




null.clob // A null clob value

{{ "This is a CLOB of text." }}

shift_jis ::
{{
'''Another clob with user-defined encoding, '''
'''this time on multiple lines.'''
}}




null.struct // A null struct value
{ } // An empty struct value
{ first : "Tom" , last: "Riddle" } // Structure with two fields
{"first":"Tom","last":"Riddle"} // The same value with confusing style
{center:{x:1.0, y:12.5}, radius:3} // Nested struct
{ x:1, } // Trailing comma is legal in Ion (unlike JSON)
{ "":42 } // A struct value containing a field with an empty name
{ x:1, x:null.int } // WARNING: repeated name 'x' leads to undefined behavior



{ field_name: annotation:: value } // Okay





null.list // A null list value
[] // An empty list value
[1, 2, 3] // List of three ints
[ 1 , two ] // List of an int and a symbol
[a , [b]] // Nested list
[ 1.2, ] // Trailing comma is legal in Ion (unlike JSON)


null.sexp // A null S-expression value
() // An empty expression value
(cons 1 2) // S-expression of three values
([hello][there]) // S-expression containing two lists

(a+-b) ( 'a' '+-' 'b' ) // Equivalent; three symbols
(a.b;) ( 'a' '.' 'b' ';') // Equivalent; four symbols


(a/* word */b) // An S-expression with two symbols and a comment
(a '/*' word '*/' b) // An S-expression with five symbols





int32::12 // Suggests 32 bits as end-user type
degrees::'celsius'::100 // You can have multiple annotaions on a value
'my.custom.type' :: { x : 12 , y : -1 } // Gives a struct a user-defined type

{ field: some_annotation::value } // Field's name must precede annotations of its value

bool :: null.int // A very misleading annotation on the integer null
'' :: 1 // An empty annotation

Loading

1 comment on commit e47058e

@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: e47058e Previous: 50b55e3 Ratio
arith_agg-avg 741112 ns/iter (± 11768) 745668 ns/iter (± 8289) 0.99
arith_agg-avg_distinct 852921 ns/iter (± 4734) 842211 ns/iter (± 2984) 1.01
arith_agg-count 793756 ns/iter (± 13651) 796805 ns/iter (± 14937) 1.00
arith_agg-count_distinct 836986 ns/iter (± 13887) 839717 ns/iter (± 2295) 1.00
arith_agg-min 798002 ns/iter (± 4876) 809296 ns/iter (± 9723) 0.99
arith_agg-min_distinct 842278 ns/iter (± 15118) 842054 ns/iter (± 3423) 1.00
arith_agg-max 811590 ns/iter (± 1576) 818618 ns/iter (± 2222) 0.99
arith_agg-max_distinct 865126 ns/iter (± 1937) 849078 ns/iter (± 3352) 1.02
arith_agg-sum 799896 ns/iter (± 2260) 809141 ns/iter (± 2021) 0.99
arith_agg-sum_distinct 844440 ns/iter (± 2708) 840527 ns/iter (± 4139) 1.00
arith_agg-avg-count-min-max-sum 973746 ns/iter (± 4891) 982795 ns/iter (± 3938) 0.99
arith_agg-avg-count-min-max-sum-group_by 1360779 ns/iter (± 5783) 1384992 ns/iter (± 5906) 0.98
arith_agg-avg-count-min-max-sum-group_by-group_as 1986080 ns/iter (± 10279) 1976131 ns/iter (± 15529) 1.01
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct 1205610 ns/iter (± 10681) 1205495 ns/iter (± 17123) 1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by 1658541 ns/iter (± 9423) 1598967 ns/iter (± 15618) 1.04
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as 2223558 ns/iter (± 9385) 2142144 ns/iter (± 12337) 1.04
parse-1 5564 ns/iter (± 134) 5399 ns/iter (± 192) 1.03
parse-15 46850 ns/iter (± 244) 45704 ns/iter (± 1032) 1.03
parse-30 90394 ns/iter (± 270) 91935 ns/iter (± 689) 0.98
compile-1 4309 ns/iter (± 12) 4225 ns/iter (± 31) 1.02
compile-15 32040 ns/iter (± 128) 31008 ns/iter (± 112) 1.03
compile-30 65575 ns/iter (± 244) 64300 ns/iter (± 411) 1.02
plan-1 67955 ns/iter (± 1546) 67636 ns/iter (± 254) 1.00
plan-15 1056653 ns/iter (± 19118) 1052597 ns/iter (± 8313) 1.00
plan-30 2199639 ns/iter (± 8591) 2106557 ns/iter (± 15988) 1.04
eval-1 12546480 ns/iter (± 129536) 12447246 ns/iter (± 72516) 1.01
eval-15 90926473 ns/iter (± 440317) 89828917 ns/iter (± 1241143) 1.01
eval-30 174690094 ns/iter (± 355655) 170627821 ns/iter (± 731867) 1.02
join 10054 ns/iter (± 74) 10274 ns/iter (± 45) 0.98
simple 2471 ns/iter (± 9) 2425 ns/iter (± 10) 1.02
simple-no 478 ns/iter (± 1) 462 ns/iter (± 6) 1.03
numbers 57 ns/iter (± 0) 57 ns/iter (± 0) 1
parse-simple 671 ns/iter (± 3) 750 ns/iter (± 15) 0.89
parse-ion 2313 ns/iter (± 6) 2336 ns/iter (± 20) 0.99
parse-group 7300 ns/iter (± 14) 7049 ns/iter (± 49) 1.04
parse-complex 19088 ns/iter (± 109) 18568 ns/iter (± 103) 1.03
parse-complex-fexpr 28846 ns/iter (± 178) 25704 ns/iter (± 153) 1.12

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

Please sign in to comment.