Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr committed Feb 3, 2025
1 parent 68f01d4 commit 9cba19d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
8 changes: 5 additions & 3 deletions extension/partiql-extension-ion/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@ impl PartiqlEncodedIonValueDecoder {
R: IonReader<Item = StreamItem, Symbol = Symbol>,
{
let mut loader = ion_elt::ElementLoader::for_reader(reader);
let elt = loader.materialize_current()?.unwrap();
let elt = loader
.materialize_current()?
.ok_or_else(|| IonDecodeError::StreamError("No current value found".into()))?;
let ion_ctor = Box::new(BoxedIonType {});
let contents = elt.to_string();
Ok(Value::from(
Expand Down Expand Up @@ -660,7 +662,7 @@ mod ion_elt {
}

/// Steps into the current sequence and materializes each of its children to construct
/// an [`Vec<Element>`]. When all of the the children have been materialized, steps out.
/// an [`Vec<Element>`]. When all of the children have been materialized, steps out.
/// The reader MUST be positioned over a list or s-expression when this is called.
fn materialize_sequence(&mut self) -> IonResult<Sequence> {
let mut child_elements = Vec::new();
Expand All @@ -673,7 +675,7 @@ mod ion_elt {
}

/// Steps into the current struct and materializes each of its fields to construct
/// an [`Struct`]. When all of the the fields have been materialized, steps out.
/// an [`Struct`]. When all of the fields have been materialized, steps out.
/// The reader MUST be positioned over a struct when this is called.
fn materialize_struct(&mut self) -> IonResult<Struct> {
let mut child_elements = Vec::new();
Expand Down
23 changes: 17 additions & 6 deletions partiql/tests/ion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,22 @@ fn ion_iter() {

#[test]
fn ion_cmp() {
let query = "`foo` < `bar` OR `1.2` > `1`";
let queries = [
["struct", "{ 'ion_lt_pql': `1` < 2, 'pql_lt_ion': 1 < `2`}"],
[
"ORDER BY",
"SELECT x from <<`1`, 2, `3`, 4, `5`, 3+`3`>> as x ORDER BY x",
],
["ORed", "`foo` < `bar` OR `1.2` > `1`"],
];
for [name, query] in queries {
let res = eval(query, EvaluationMode::Permissive);
assert_matches!(res, Ok(_));
let result = res.unwrap().result;

let res = eval(query, EvaluationMode::Permissive);
assert_matches!(res, Ok(_));
let result = res.unwrap().result;

insta::assert_snapshot!(result.to_pretty_string(25).expect("pretty"));
insta::assert_snapshot!(
format!("ion_cmp_{name}"),
result.to_pretty_string(25).expect("pretty")
);
}
}
12 changes: 12 additions & 0 deletions partiql/tests/snapshots/ion__ion_cmp_ORDER BY.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: partiql/tests/ion.rs
expression: "result.to_pretty_string(25).expect(\"pretty\")"
---
[
{ 'x': `1`::ion },
{ 'x': 2 },
{ 'x': `3`::ion },
{ 'x': 4 },
{ 'x': `5`::ion },
{ 'x': 6 }
]
File renamed without changes.
8 changes: 8 additions & 0 deletions partiql/tests/snapshots/ion__ion_cmp_struct.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
source: partiql/tests/ion.rs
expression: "result.to_pretty_string(25).expect(\"pretty\")"
---
{
'ion_lt_pql': true,
'pql_lt_ion': true
}

0 comments on commit 9cba19d

Please sign in to comment.